Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: reHackable/maxio
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: rmkit-dev/maxio
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 3 commits
  • 64 files changed
  • 1 contributor

Commits on Oct 3, 2020

  1. Copy the full SHA
    59c075b View commit details

Commits on Oct 16, 2020

  1. [pens] update pens

    okay committed Oct 16, 2020
    Copy the full SHA
    d72cdfa View commit details
  2. [export] export to svg instead of pdf

    okay committed Oct 16, 2020
    Copy the full SHA
    4fc23fc View commit details
Showing with 301 additions and 5 deletions.
  1. BIN templates/Blank.png
  2. BIN templates/Isometric.png
  3. BIN templates/LS Checklist double.png
  4. BIN templates/LS Checklist.png
  5. BIN templates/LS Dayplanner.png
  6. BIN templates/LS Dots bottom.png
  7. BIN templates/LS Dots top.png
  8. BIN templates/LS Four storyboards.png
  9. BIN templates/LS Grid bottom.png
  10. BIN templates/LS Grid margin large.png
  11. BIN templates/LS Grid margin med.png
  12. BIN templates/LS Grid top.png
  13. BIN templates/LS Lines bottom.png
  14. BIN templates/LS Lines medium.png
  15. BIN templates/LS Lines small.png
  16. BIN templates/LS Lines top.png
  17. BIN templates/LS Margin medium.png
  18. BIN templates/LS Margin small.png
  19. BIN templates/LS One storyboard 2.png
  20. BIN templates/LS One storyboard.png
  21. BIN templates/LS Two storyboards.png
  22. BIN templates/LS Week US.png
  23. BIN templates/LS Week.png
  24. BIN templates/Notes.png
  25. BIN templates/P Black dots.png
  26. BIN templates/P Black grid.png
  27. BIN templates/P Black lines.png
  28. BIN templates/P Black.png
  29. BIN templates/P Checklist.png
  30. BIN templates/P Cornell.png
  31. BIN templates/P Day.png
  32. BIN templates/P Dots S bottom.png
  33. BIN templates/P Dots S top.png
  34. BIN templates/P Dots S.png
  35. BIN templates/P Dots large.png
  36. BIN templates/P Four storyboards.png
  37. BIN templates/P Grid bottom.png
  38. BIN templates/P Grid large.png
  39. BIN templates/P Grid margin large.png
  40. BIN templates/P Grid margin med.png
  41. BIN templates/P Grid medium.png
  42. BIN templates/P Grid small.png
  43. BIN templates/P Grid top.png
  44. BIN templates/P Lined bottom.png
  45. BIN templates/P Lined heading.png
  46. BIN templates/P Lined top.png
  47. BIN templates/P Lines large.png
  48. BIN templates/P Lines medium.png
  49. BIN templates/P Lines small.png
  50. BIN templates/P Margin large.png
  51. BIN templates/P Margin medium.png
  52. BIN templates/P Margin small.png
  53. BIN templates/P One storyboard.png
  54. BIN templates/P Two storyboards.png
  55. BIN templates/P US College.png
  56. BIN templates/P US Legal.png
  57. BIN templates/P Week 2.png
  58. BIN templates/P Week US.png
  59. BIN templates/P Week.png
  60. BIN templates/Perspective1.png
  61. BIN templates/Perspective2.png
  62. +260 −0 tools/exportFromZip
  63. +37 −0 tools/genHtmlFromPDF
  64. +4 −5 tools/rM2svg
Binary file added templates/Blank.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/Isometric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Checklist double.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Checklist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Dayplanner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Dots bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Dots top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Four storyboards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Grid bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Grid margin large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Grid margin med.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Grid top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Lines bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Lines medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Lines small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Lines top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Margin medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Margin small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS One storyboard 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS One storyboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Two storyboards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Week US.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/LS Week.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/Notes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/P Black dots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added templates/P Black grid.png
Binary file added templates/P Black lines.png
Binary file added templates/P Black.png
Binary file added templates/P Checklist.png
Binary file added templates/P Cornell.png
Binary file added templates/P Day.png
Binary file added templates/P Dots S bottom.png
Binary file added templates/P Dots S top.png
Binary file added templates/P Dots S.png
Binary file added templates/P Dots large.png
Binary file added templates/P Four storyboards.png
Binary file added templates/P Grid bottom.png
Binary file added templates/P Grid large.png
Binary file added templates/P Grid margin large.png
Binary file added templates/P Grid margin med.png
Binary file added templates/P Grid medium.png
Binary file added templates/P Grid small.png
Binary file added templates/P Grid top.png
Binary file added templates/P Lined bottom.png
Binary file added templates/P Lined heading.png
Binary file added templates/P Lined top.png
Binary file added templates/P Lines large.png
Binary file added templates/P Lines medium.png
Binary file added templates/P Lines small.png
Binary file added templates/P Margin large.png
Binary file added templates/P Margin medium.png
Binary file added templates/P Margin small.png
Binary file added templates/P One storyboard.png
Binary file added templates/P Two storyboards.png
Binary file added templates/P US College.png
Binary file added templates/P US Legal.png
Binary file added templates/P Week 2.png
Binary file added templates/P Week US.png
Binary file added templates/P Week.png
Binary file added templates/Perspective1.png
Binary file added templates/Perspective2.png
260 changes: 260 additions & 0 deletions tools/exportFromZip
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
#!/usr/bin/env bash

# Needs:
# - ssh and scp (openssh)
# - convert (imagemagick)
# - pdftk (pdftk)
# - rsvg-convert (optional, to avoid rasterizing of lines)
# - gs & pdfinfo (optional, to account for original pdf size)


ASK_RENAME=""
COLOR_ANNOTATIONS=""
SSH_HOST="10.11.99.1"
SSH_TIMEOUT=1
path=""
STROKE_WIDTH="3"
OPACITY="1"
bad_args=""
arg_num=0
KEEP_TEMPDIR=""

while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-n|--askrename)
ASK_RENAME=true
shift
;;
-c|--coloured_annotations)
COLOR_ANNOTATIONS=true
shift
;;
-k|--keep_tempdir)
KEEP_TEMPDIR=true
shift
;;
-r|--remoteip)
SSH_HOST="$2"
SSH_TIMEOUT=10
shift
shift
;;
-w|--strokewidth)
STROKE_WIDTH="$2"
shift
shift
;;
-o|--opacity)
OPACITY="$2"
shift
shift
;;
-*)
echo "Unknown option: $1"
bad_args=TRUE
shift
;;
*)
arg_num=$(( $arg_num + 1 ))
case $arg_num in
1)
path="$1"
shift
;;
*)
bad_args=TRUE
esac
;;
esac
done

if [[ $bad_args == TRUE || $arg_num < 1 ]]; then
echo "Usage: $(basename "$0") [--askrename|-n] [--remoteip|-r STR] [--strokewidth|-w INT] [--opacity|-o FLOAT] [--coloured_annotations|-c] [--keep_tempdir|-k] <document-name-match|tar.gz-file>"
exit 1
fi


function rmtgrep {
RET_MATCH="$(${SSH_CMD} "$SSH_REMOTE" "/bin/egrep -$1 '$2' $3")"
echo "/bin/egrep -$1 '$2' $3: $RET_MATCH"
}

declare -A DOCUMENTS_NAMES
declare -A DOCUMENTS_DATES

function find_document {
OLD_IFS=$IFS
IFS='/' _PATH=(${2#/}) # Sort path into array
IFS=$OLD_IFS

MATCH="${_PATH[$3]}"
[ ${MATCH: -1} == "$" ] && MATCH="${MATCH:0:-1}" || MATCH="${MATCH}.*"
[ ${MATCH:0:1} == "^" ] && MATCH="${MATCH:1}" || MATCH=".*${MATCH}"
rmtgrep "ile" "\"visibleName\": \"${MATCH}\"" "/home/root/.local/share/remarkable/xochitl/*.metadata"
echo $RET_MATCH
matches_by_name="$RET_MATCH"

for metadata_path in $matches_by_name; do

metadata="$(${SSH_CMD} "$SSH_REMOTE" "cat $metadata_path")"

if ! echo "$metadata" | grep -qF "\"parent\": \"$1\""; then
continue
fi

if echo "$metadata" | grep -qF '"deleted": true'; then
continue
fi

if [[ "$(expr $3 + 1)" -eq "${#_PATH[@]}" ]]; then
if echo "$metadata" | grep -qF '"type": "DocumentType"'; then
_UUID="$(basename "$metadata_path" .metadata)"
NAME="$(echo "$metadata" | grep '"visibleName"' | sed 's/^.*: \+"\([^"]\+\)"/\1/g')"
IDATE="$(echo "$metadata" | grep '"lastModified"' | egrep -o '[0-9]*')"
STRDATE="$(date -d @$(expr ${IDATE} / 1000) '+%Y-%m-%d %H:%M:%S')"
DOCUMENTS_NAMES["$_UUID"]="$NAME"
DOCUMENTS_DATES["$_UUID"]="$STRDATE"
fi
else
if echo "$metadata" | grep -qF '"type": "CollectionType"'; then
find_document "$(basename "$metadata_path" .metadata)" "$2" "$(expr $3 + 1)"
fi
fi

done
}

# Kills SSH session and exits with return 1
function exit_failed {
${SSH_CMD} -O exit "$SSH_REMOTE"
exit 1
}


# Make sure we have rM2svg
command -v rM2svg >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
rM2svg_cmd="$(dirname `readlink -f $0`)/rM2svg"
if [ ! -x "$rM2svg_cmd" ]; then
echo "Cannot find rM2svg"
exit 1
fi
else
rM2svg_cmd="rM2svg"
fi

[ -n "$COLOR_ANNOTATIONS" ] && rM2svg_cmd="$rM2svg_cmd -c"

tmpfolder=$(mktemp -d)
echo "Using temp folder '$tmpfolder'"

OUTPUT_UUID=""

if [ -f "$path" ]; then
prev=${PWD}
cp templates/*.png ${tmpfolder}/
pushd "${tmpfolder}"
unzip "${prev}/${path}"
[ ! $? -eq 0 ] && echo "File '$path' exists, but it is not a valid .tar.gz" && exit 1
echo "GETTING BASENAME", ${path}
filename=`basename "$path" .zip`
echo "GOT BASENAME", ${path}
popd
else
echo "No such file '${path}'"
exit 1
fi

# Fix for single page notebooks with no template (empty pagedata file by default)
if [ ! -s "${tmpfolder}"/*.pagedata ]; then
echo "Blank" > "${tmpfolder}"/*.pagedata
fi

# Fix empty lines in pagedata files
sed -i -e "s/^[[:blank:]]*$/Blank/" "${tmpfolder}"/*.pagedata

NPAGES="$(wc -l "${tmpfolder}"/*.pagedata | cut -d\ -f1)"
echo "Exporting '${filename}' (${NPAGES} pages)"

if [ -f "${tmpfolder}"/*.pdf ]; then
ln -s "${tmpfolder}/"*.pdf "${tmpfolder}/background_original.pdf"
echo "Found underlying document PDF, using as background."

if command -v "gs" > /dev/null && command -v "pdfinfo" > /dev/null
then
# Read PDF dimensions for scale correction
size=$(pdfinfo ${tmpfolder}/background_original.pdf | grep "Page size" | awk '{print $3,$5}')
width=$(echo ${size} | cut -f1 -d " ")
height=$(echo ${size} | cut -f2 -d " ")

# Calculate new width and necessary offset (rM dimensions: 1404x1872)
new_width=$(echo "scale=5; ${height} / 1872 * 1404" | bc)
offset=$(echo "scale=5; ${new_width} - ${width}" | bc)

echo "Original PDF dimensions are (${width}x${height}), correcting by offset of ${offset} to fit rM foreground."

# Add offset to background.pdf to match foreground dimensions
gs -q -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -sOutputFile=${tmpfolder}/background_with_offset.pdf \
-dDEVICEWIDTHPOINTS=${new_width} -dDEVICEHEIGHTPOINTS=${height} -dFIXEDMEDIA \
-c "{${offset} 0 translate}" \
-f "${tmpfolder}/background_original.pdf"

ln -s ${tmpfolder}/background_with_offset.pdf ${tmpfolder}/background.pdf
else
ln -s ${tmpfolder}/background_original.pdf ${tmpfolder}/background.pdf
fi
else

# Generate a PDF file out of the templates
sed -e "s|^|\"${tmpfolder}\"/\"|" -e 's|$|.png"|' "${tmpfolder}"/*.pagedata | tr '\n' ' ' | sed -e "s|$|-transparent white \"${tmpfolder}\"/background.pdf|" | xargs convert
[ ! $? -eq 0 ] && echo "Failed to generate a PDF file out of the templates" && exit 1
fi

# Extract annotations and create a PDF
IPAGE=0
jq '.pages' "${tmpfolder}"/*.content | jq '.[]' | while read -r page; do
SPAGE="${page:1:${#page}-2}"
let OPAGE=IPAGE
let IPAGE=IPAGE+1
if [ -f "${tmpfolder}"/*/"${OPAGE}.rm" ]; then
echo "Processing page $IPAGE ($SPAGE)"
echo $rM2svg_cmd --input "${tmpfolder}"/*/"${OPAGE}.rm" --output "${tmpfolder}/foreground$(printf %03d $IPAGE).svg"
$rM2svg_cmd --input "${tmpfolder}"/*/"${OPAGE}.rm" --output "${tmpfolder}/foreground$(printf %03d $IPAGE).svg"
[ ! $? -eq 0 ] && echo "Failed to generate '${tmpfolder}/foreground$(printf %03d $IPAGE).svg'" && exit 1
else
echo "Generating empty page $IPAGE ($IPAGE)"
cat << 'EOF' > "${tmpfolder}/foreground$(printf %03d $IPAGE).svg"
<svg xmlns="http://www.w3.org/2000/svg" height="1872" width="1404">
<script type="application/ecmascript"> <![CDATA[
var visiblePage = 'p1';
function goToPage(page) {
document.getElementById(visiblePage).setAttribute('style', 'display: none');
document.getElementById(page).setAttribute('style', 'display: inline');
visiblePage = page;
}
]]> </script>
<g id="p1" style="display:inline">
<rect x="0" y="0" width="1404" height="1872" fill-opacity="0"/></g></svg>
EOF
fi
done

# Preprocess foreground*.svg
for f in "${tmpfolder}"/foreground*.svg; do
# debug
#cp -v "$f" ~/debug/"$(basename "$f")"
sed "s/stroke-width\:[\.0-9]\+/stroke-width:${STROKE_WIDTH}/g;s/opacity\:[\.0-9]\+/opacity:${OPACITY}/g" "$f" > "$f.clean"
[ ! $? -eq 0 ] && echo "Failed to reset stroke-width and opacity in '$f'" && exit 1
done

# - optimize svg with svgo
if command -v "svgo" > /dev/null; then
for f in "${tmpfolder}"/foreground*.svg; do
svgo -i "$f"
[ ! $? -eq 0 ] && echo "Failed to optimize svg '$f'" && continue
done
fi

mkdir -p "${filename}" 2>/dev/null
cp "${tmpfolder}"/foreground*.svg "${filename}"
37 changes: 37 additions & 0 deletions tools/genHtmlFromPDF
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
HEADER=`cat <<END_HEADER
<html>

<style>
img {
max-width: 400px;
display: inline-block;
}

body {
width: 840px;
margin: auto;
}
</style>
END_HEADER
`

FOOTER=`cat << END_FOOTER
</html>
END_FOOTER
`

pdf="$1"
outfile="${pdf/.pdf/.html}"
outdir=${pdf/.pdf}

mkdir "${outdir}"
echo ${HEADER} > ${outfile}
convert ${1} ${1/pdf/png}
for i in ${1/.pdf/}*png; do
echo "<a href='${i}'><img src='${i}' /></a>" >> ${outfile}
cp ${i} ${outdir}
done

echo ${FOOTER} >> ${outfile}

mv ${outfile} ${outdir}
9 changes: 4 additions & 5 deletions tools/rM2svg
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ import re
__prog_name__ = "rm2svg"
__version__ = "0.0.2.1"


# Size
default_x_width = 1404
default_y_width = 1872
@@ -155,20 +154,20 @@ def rm2svg(input_file, output_name, coloured_annotations=False,
#print('Unexpected value at offset {}'.format(offset - 12))
if pen == 0 or pen == 1:
pass # Dynamic width, will be truncated into several strokes
elif pen == 2 or pen == 4: # Pen / Fineliner
elif pen == 2 or pen == 4 or pen == 15 or pen == 17: # Pen / Fineliner
width = 32 * width * width - 116 * width + 107
elif pen == 3: # Marker
elif pen == 3 or pen == 16 or pen == 12: # Marker
width = 64 * width - 112
opacity = 0.9
elif pen == 5: # Highlighter
elif pen == 5 or pen == 18: # Highlighter
width = 30
opacity = 0.2
if coloured_annotations:
colour = 3
elif pen == 6: # Eraser
width = 1280 * width * width - 4800 * width + 4510
colour = 2
elif pen == 7: # Pencil-Sharp
elif pen == 7 or pen == 13 or pen == 14: # Pencil-Sharp
width = 16 * width - 27
opacity = 0.9
elif pen == 8: # Erase area