-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: sync commits from swe-productivity study (#616) #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8665103
99d2635
4685b75
3e87190
9b77670
7c980f4
89c3bd2
efec1d5
3e3d2de
5eaca58
c58b4f8
ed63bc5
610f1f6
484545c
a90a5da
666bc49
3bb36c4
917c118
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| if [ -n "$MAGICK_MAX_WIDTH" ]; then | ||
| if ! [[ "$MAGICK_MAX_WIDTH" =~ ^[0-9]+$ ]]; then | ||
| echo "Error: MAGICK_MAX_WIDTH must be a positive integer in pixels" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| if [ -n "$MAGICK_MAX_HEIGHT" ]; then | ||
| if ! [[ "$MAGICK_MAX_HEIGHT" =~ ^[0-9]+$ ]]; then | ||
| echo "Error: MAGICK_MAX_HEIGHT must be a positive integer in pixels" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| if [ -n "$MAGICK_MAX_WIDTH" ] || [ -n "$MAGICK_MAX_HEIGHT" ]; then | ||
| POLICY_DIR="/etc/ImageMagick-7" | ||
| POLICY_FILE="$POLICY_DIR/policy.xml" | ||
|
|
||
| if [ -f "$POLICY_FILE" ] && grep -q "</policymap>" "$POLICY_FILE"; then | ||
| [ -n "$MAGICK_MAX_WIDTH" ] && sed -i '/<policy domain="resource" name="width"/d' "$POLICY_FILE" | ||
| [ -n "$MAGICK_MAX_HEIGHT" ] && sed -i '/<policy domain="resource" name="height"/d' "$POLICY_FILE" | ||
| if [ -n "$MAGICK_MAX_WIDTH" ]; then | ||
| sed -i "s|</policymap>| <policy domain=\"resource\" name=\"width\" value=\"$MAGICK_MAX_WIDTH\"/>\n</policymap>|" "$POLICY_FILE" | ||
| fi | ||
| if [ -n "$MAGICK_MAX_HEIGHT" ]; then | ||
| sed -i "s|</policymap>| <policy domain=\"resource\" name=\"height\" value=\"$MAGICK_MAX_HEIGHT\"/>\n</policymap>|" "$POLICY_FILE" | ||
| fi | ||
| else | ||
| mkdir -p "$POLICY_DIR" | ||
| echo "<policymap>" > "$POLICY_FILE" | ||
| if [ -n "$MAGICK_MAX_WIDTH" ]; then | ||
| echo " <policy domain=\"resource\" name=\"width\" value=\"$MAGICK_MAX_WIDTH\"/>" >> "$POLICY_FILE" | ||
| fi | ||
| if [ -n "$MAGICK_MAX_HEIGHT" ]; then | ||
| echo " <policy domain=\"resource\" name=\"height\" value=\"$MAGICK_MAX_HEIGHT\"/>" >> "$POLICY_FILE" | ||
| fi | ||
| echo "</policymap>" >> "$POLICY_FILE" | ||
| fi | ||
| fi | ||
|
|
||
| exec bun run dist/src/index.js | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,56 @@ const jobId = window.location.pathname.split("/").pop(); | |||||||||
| const main = document.querySelector("main"); | ||||||||||
| let progressElem = document.querySelector("progress"); | ||||||||||
|
|
||||||||||
| const supportsWebShare = navigator.share && navigator.canShare; | ||||||||||
|
|
||||||||||
| const setupShareButtons = () => { | ||||||||||
| if (!supportsWebShare) { | ||||||||||
| return; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| document.querySelectorAll(".share-btn").forEach((btn) => { | ||||||||||
| if (btn.dataset.setupComplete) return; | ||||||||||
|
|
||||||||||
| const filename = btn.dataset.filename; | ||||||||||
| const mimeType = btn.dataset.mimeType; | ||||||||||
| const fileUrl = btn.dataset.downloadUrl; | ||||||||||
| const dummyFile = new File([], filename, { type: mimeType }); | ||||||||||
|
|
||||||||||
| if (!navigator.canShare({ files: [dummyFile] })) { | ||||||||||
| return; | ||||||||||
| } | ||||||||||
| let cachedFile = null; | ||||||||||
| let isFetching = false; | ||||||||||
|
|
||||||||||
| btn.addEventListener("click", async (e) => { | ||||||||||
| e.preventDefault(); | ||||||||||
| if (isFetching) return; | ||||||||||
| try { | ||||||||||
| if (!cachedFile) { | ||||||||||
| isFetching = true; | ||||||||||
|
Comment on lines
+31
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: After the first attempt caches the file, this branch skips Prompt for AI agents
Suggested change
|
||||||||||
| const response = await fetch(fileUrl); | ||||||||||
| if (!response.ok) { | ||||||||||
| throw new Error(`Failed to download file (${response.status})`); | ||||||||||
| } | ||||||||||
| const blob = await response.blob(); | ||||||||||
| cachedFile = new File([blob], filename, { type: mimeType }); | ||||||||||
| } | ||||||||||
| await navigator.share({ files: [cachedFile] }); | ||||||||||
| } catch (err) { | ||||||||||
| if (err.name === "NotAllowedError" && cachedFile) { | ||||||||||
| alert("File is ready. Please tap the share button again to share."); | ||||||||||
| } else if (err.name !== "AbortError") { | ||||||||||
| console.error("Error sharing:", err); | ||||||||||
| } | ||||||||||
| } finally { | ||||||||||
| isFetching = false; | ||||||||||
| } | ||||||||||
| }); | ||||||||||
| btn.style.display = ""; | ||||||||||
| btn.dataset.setupComplete = true; | ||||||||||
| }); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| const refreshData = () => { | ||||||||||
| // console.log("Refreshing data...", progressElem.value, progressElem.max); | ||||||||||
| if (progressElem.value !== progressElem.max) { | ||||||||||
|
|
@@ -12,6 +62,7 @@ const refreshData = () => { | |||||||||
| .then((res) => res.text()) | ||||||||||
| .then((html) => { | ||||||||||
| main.innerHTML = html; | ||||||||||
| setupShareButtons(); | ||||||||||
| }) | ||||||||||
| .catch((err) => console.log(err)); | ||||||||||
|
|
||||||||||
|
|
@@ -21,6 +72,7 @@ const refreshData = () => { | |||||||||
| progressElem = document.querySelector("progress"); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| setupShareButtons(); | ||||||||||
| refreshData(); | ||||||||||
|
|
||||||||||
| window.downloadAll = function () { | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: When
MAGICK_MAX_WIDTHorMAGICK_MAX_HEIGHTis set to0, this check accepts it despite requiring a positive integer, then writes a zero ImageMagick dimension limit. Reject zero values so invalid configuration fails at startup rather than making normal image conversions exceed the limit.Prompt for AI agents