mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
refatoring image upload error
This commit is contained in:
@@ -23,7 +23,7 @@ Development command: `dotnet watch --project Management.Web/`
|
|||||||
### Enable Image Support
|
### Enable Image Support
|
||||||
|
|
||||||
|
|
||||||
You must set the `ENABLE_FILE_SYNC` environment variable to true. Images need to be available in the `/app/public/` directory in the container so that nextjs will serve them as static files. Images can also be set to public URL's on the web.
|
You must set the `NEXT_PUBLIC_ENABLE_FILE_SYNC` environment variable to true. Images need to be available in the `/app/public/` directory in the container so that nextjs will serve them as static files. Images can also be set to public URL's on the web.
|
||||||
|
|
||||||
When an image is detected by canvas manager, it will upload the image to the canvas course and keep a lookup table of the original path/url of the image to the canvas course URL.
|
When an image is detected by canvas manager, it will upload the image to the canvas course and keep a lookup table of the original path/url of the image to the canvas course URL.
|
||||||
|
|
||||||
|
|||||||
2
build.sh
2
build.sh
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
MAJOR_VERSION="2"
|
MAJOR_VERSION="2"
|
||||||
MINOR_VERSION="5"
|
MINOR_VERSION="6"
|
||||||
VERSION="$MAJOR_VERSION.$MINOR_VERSION"
|
VERSION="$MAJOR_VERSION.$MINOR_VERSION"
|
||||||
|
|
||||||
TAG_FLAG=false
|
TAG_FLAG=false
|
||||||
|
|||||||
3
run.sh
3
run.sh
@@ -4,7 +4,7 @@ docker run -it --rm \
|
|||||||
--name canvas-manager-2 \
|
--name canvas-manager-2 \
|
||||||
-e TZ=America/Denver \
|
-e TZ=America/Denver \
|
||||||
-e NODE_ENV=development \
|
-e NODE_ENV=development \
|
||||||
-e NEXT_PUBLIC_ENABLE_FILE_SYNC=true \
|
-e "NEXT_PUBLIC_ENABLE_FILE_SYNC=true" \
|
||||||
-u 1000:1000 \
|
-u 1000:1000 \
|
||||||
-p 3000:3000 \
|
-p 3000:3000 \
|
||||||
-w /app \
|
-w /app \
|
||||||
@@ -16,6 +16,7 @@ docker run -it --rm \
|
|||||||
-v ~/projects/faculty/1405/2025_spring_alex:/app/storage/1405 \
|
-v ~/projects/faculty/1405/2025_spring_alex:/app/storage/1405 \
|
||||||
-v ~/projects/faculty/3840_Telemetry/2025_spring_alex/modules:/app/storage/telemetry \
|
-v ~/projects/faculty/3840_Telemetry/2025_spring_alex/modules:/app/storage/telemetry \
|
||||||
-v ~/projects/faculty/4620_Distributed/2025Spring/modules:/app/storage/distributed \
|
-v ~/projects/faculty/4620_Distributed/2025Spring/modules:/app/storage/distributed \
|
||||||
|
-v ~/projects/public:/app/public/images/public \
|
||||||
-v ~/projects/facultyFiles:/app/public/images/facultyFiles \
|
-v ~/projects/facultyFiles:/app/public/images/facultyFiles \
|
||||||
node \
|
node \
|
||||||
sh -c "
|
sh -c "
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export default function Modal({
|
|||||||
: " bg-opacity-0 -z-50 ")
|
: " bg-opacity-0 -z-50 ")
|
||||||
}
|
}
|
||||||
onClick={modalControl.closeModal}
|
onClick={modalControl.closeModal}
|
||||||
|
// if mouse up here, do not, if mouse down then still do
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const useUpdateImageSettingsForAssignment = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!enable_images) {
|
if (!enable_images) {
|
||||||
console.log("not uploading images, FILE_POLLING is not set to true");
|
console.log("not uploading images, NEXT_PUBLIC_ENABLE_FILE_SYNC is not set to true");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +70,7 @@ export const useAddNewImagesToCanvasMutation = () => {
|
|||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async ({ markdownString }: { markdownString: string }) => {
|
mutationFn: async ({ markdownString }: { markdownString: string }) => {
|
||||||
const imageSources = extractImageSources(markdownString);
|
const imageSources = extractImageSources(markdownString);
|
||||||
|
// console.log("original image urls", imageSources);
|
||||||
const newImages = imageSources.filter((source) =>
|
const newImages = imageSources.filter((source) =>
|
||||||
settings.assets.every((a) => a.sourceUrl !== source)
|
settings.assets.every((a) => a.sourceUrl !== source)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { marked } from "marked";
|
|||||||
import DOMPurify from "isomorphic-dompurify";
|
import DOMPurify from "isomorphic-dompurify";
|
||||||
import { LocalCourseSettings } from "@/models/local/localCourseSettings";
|
import { LocalCourseSettings } from "@/models/local/localCourseSettings";
|
||||||
import markedKatex from "marked-katex-extension";
|
import markedKatex from "marked-katex-extension";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
marked.use(
|
marked.use(
|
||||||
markedKatex({
|
markedKatex({
|
||||||
@@ -37,8 +38,12 @@ export function convertImagesToCanvasImages(
|
|||||||
for (const imageSrc of imageSources) {
|
for (const imageSrc of imageSources) {
|
||||||
const destinationUrl = imageLookup[imageSrc];
|
const destinationUrl = imageLookup[imageSrc];
|
||||||
if (typeof destinationUrl === "undefined") {
|
if (typeof destinationUrl === "undefined") {
|
||||||
throw `cannot convert to html, no canvas url for ${imageSrc} in settings`;
|
console.log(`No image in settings for ${imageSrc}, do you have NEXT_PUBLIC_ENABLE_FILE_SYNC=true in your settings?`)
|
||||||
}
|
}
|
||||||
|
// could error check here, but better to just not display an image...
|
||||||
|
// if (typeof destinationUrl === "undefined") {
|
||||||
|
// throw `cannot convert to html, no canvas url for ${imageSrc} in settings`;
|
||||||
|
// }
|
||||||
mutableHtml = mutableHtml.replaceAll(imageSrc, destinationUrl);
|
mutableHtml = mutableHtml.replaceAll(imageSrc, destinationUrl);
|
||||||
}
|
}
|
||||||
return mutableHtml;
|
return mutableHtml;
|
||||||
|
|||||||
Reference in New Issue
Block a user