Commit 9445fb53 authored by Adam Moore's avatar Adam Moore

Hacking in some stuff to get Alph links treated specially.

parent 306ac624
Pipeline #52052895 failed with stages
in 1 minute and 24 seconds
......@@ -362,6 +362,12 @@ def post():
#
# For now, return the unmodified metadata.
return get()
elif "fileFormat" in meta["descriptor"]:
# Do some voodoo when POSTing an Alph link to an .alink file.
if meta["descriptor"]["fileFormat"].startswith("application/alink+json"):
return postAlink(meta)
else:
return get()
else:
# Okay, new data is being appended to an existing file, or a new file
# is being created.
......@@ -561,6 +567,16 @@ def appendPostedText(meta):
json.dump(meta,open(docpath + ".meta",mode='w+',encoding='utf-8'))
return
def postAlink(meta):
# Alph link files can contain multiple links, so when a JSON Alph link is
# POSTed to an .alink file, add/replace the link in the file.
global debugtext
postdata = form["media"]
#...
def postFile(meta):
global debugtext
......@@ -1042,6 +1058,7 @@ def dirListing(user):
furl = urlroot + urlpath + os.path.basename(ix) + ("/" if ixisdir else "")
fname = os.path.basename(ix) + ("/" if ixisdir else "")
# Include a link to a viewer page?
if not os.path.isfile(ix + ".html") and not ix.endswith(".html") and not os.path.isdir(ix):
viewer = '<small>(<a href="' + os.path.basename(ix) + '.html">html</a>)</small>'
......@@ -1054,6 +1071,10 @@ def dirListing(user):
else:
if "fileFormat" in fmeta["descriptor"].keys():
ftype = fmeta["descriptor"]["fileFormat"].split(";")[0]
# Bit of a hack, here but... let's sneak the media type
# into the anchor as well, via the furl
furl = furl + "' type='" + ftype
else:
ftype = ""
......@@ -1336,9 +1357,14 @@ def makeMediaMeta(meta,f):
# "http://alph.io/interfaces/fragment"]
# 'file' doesn't know what to do with a lot of plain text formats, so force some here.
if mimestring.startswith("text") and extension.lower() == "css":
mimetype = "text/css"
if mimestring.startswith("text"):
if extension.lower() == "css":
mimetype = "text/css"
elif extension.lower() == "alink":
mimetype = "application/alink+json"
mimestring = mimetype + "; " + encoding
if mimestring.startswith("video") or mimestring.startswith("audio"):
# Call exiftool if it's video/audio, because 'file' gets the MIME type wrong
......
......@@ -2,7 +2,6 @@
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
......@@ -10,14 +9,40 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.0"
width="85"
height="85"
id="svg2"
inkscape:version="0.48.5 r10040"
sodipodi:docname="alph.svg">
width="0.78518707in"
height="0.78488189in"
viewBox="0 0 19.943751 19.936"
version="1.1"
id="svg5195"
sodipodi:docname="alph-logo-2.svg"
inkscape:version="0.92.1 r15371">
<defs
id="defs5189" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.2290146"
inkscape:cx="-29.877096"
inkscape:cy="23.261436"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
units="in"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1366"
inkscape:window-height="752"
inkscape:window-x="0"
inkscape:window-y="16"
inkscape:window-maximized="0" />
<metadata
id="metadata3037">
id="metadata5192">
<rdf:RDF>
<cc:Work
rdf:about="">
......@@ -28,67 +53,15 @@
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1366"
inkscape:window-height="768"
id="namedview3035"
showgrid="false"
inkscape:zoom="6.9882353"
inkscape:cx="17.12232"
inkscape:cy="52.331075"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg2">
<sodipodi:guide
position="0,0"
orientation="0,85"
id="guide2993" />
<sodipodi:guide
position="85,0"
orientation="-85,0"
id="guide2995" />
<sodipodi:guide
position="85,85"
orientation="0,-85"
id="guide2997" />
<sodipodi:guide
position="0,85"
orientation="85,0"
id="guide2999" />
</sodipodi:namedview>
<defs
id="defs4">
<linearGradient
id="linearGradient5215"
osb:paint="solid">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop5217" />
</linearGradient>
</defs>
<path
sodipodi:type="arc"
style="fill:#ffffff;stroke:#ffffff;stroke-opacity:1"
id="path3039-3"
sodipodi:cx="39.208755"
sodipodi:cy="40.782829"
sodipodi:rx="36.632996"
sodipodi:ry="36.632996"
d="m 75.841751,40.782829 a 36.632996,36.632996 0 1 1 -73.2659911,0 36.632996,36.632996 0 1 1 73.2659911,0 z"
transform="matrix(-0.29571762,1.1036332,-1.1036332,-0.29571762,99.149775,11.517288)" />
<path
style="fill:#000000;stroke:none"
d="m 38.261391,7.4701179 0,1.25 0,15.1562501 -34.4999998,16.5625 -2.3125,1.09375 2.28125,1.15625 34.5312498,17.375 0,16.53125 0,1.25 1.25,0 7.9375,0 1.25,0 0,-1.25 0,-11.28125 19.5625,9.84375 0.4375,0.21875 c 2.867135,-2.293715 5.456917,-4.956539 7.65625,-7.96875 l -1.28125,-0.65625 -26.375,-13.15625 0,-22.78125 26.09375,-12.4375 1.34375,-0.625 c -2.281267,-3.072369 -4.986553,-5.850849 -8.0625,-8.2187501 l -0.375,0.1875 -19,9.1562501 0,-10.1562501 0,-1.25 -1.25,0 -7.9375,0 -1.25,0 z m 0,28.3125001 0,12.59375 -12.90625,-6.40625 12.90625,-6.1875 z"
id="path3039"
inkscape:connector-curvature="0" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-38.163903,-135.0519)">
<path
inkscape:connector-curvature="0"
id="path5106"
d="m 47.917187,135.1019 a 9.921875,9.921875 0 0 0 -3.271118,0.63149 l 1.453141,2.51716 z m 2.861841,0.36174 -3.144511,5.44618 3.661275,6.3407 h 6.49676 a 9.921875,9.921875 0 0 0 0.265102,-2.23449 9.921875,9.921875 0 0 0 -7.278626,-9.55239 z m -8.471835,1.53789 a 9.921875,9.921875 0 0 0 -4.09329,8.0145 9.921875,9.921875 0 0 0 1.228866,4.76198 l 5.121134,-8.86819 z m 3.792017,6.56756 -2.125452,3.68143 h 4.250904 z m -6.57996,6.34173 a 9.921875,9.921875 0 0 0 8.616528,5.02708 9.921875,9.921875 0 0 0 4.026111,-0.86713 l -2.401404,-4.15995 h -8.089428 z m 13.312365,0 1.597319,2.76675 a 9.921875,9.921875 0 0 0 2.329057,-2.76675 z"
style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</svg>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment