#3 Added 1337box

开启中
shmalebx9 请求将 1 次代码提交从 shmalebx9/dev 合并至 untitled/master
共有 3 个文件被更改,包括 18 次插入1 次删除
  1. 1 1
      build
  2. 15 0
      filters/1337box.lua
  3. 2 0
      www-example/bunnies/site/template.include

+ 1 - 1
build

@@ -512,7 +512,7 @@ mkhtml() {
 	# Same for $TITLE
 	pandoc -V lang=${PAGELANGUAGE} -V dir=${PDIR} $TOC $SMART "$TMPFILE" \
 		-V antisocialurl="${HTMLLINK}" -s ${CSS} ${CSSOVERRIDE} ${TITLE} \
-		--template ${TEMPLATE} --metadata return="" > "$FILE.html"
+		--template ${TEMPLATE} --metadata return="" --lua-filter=filters/1337box.lua > "$FILE.html"
 
 	# generate section title anchors as [link]
 	sed -i \

+ 15 - 0
filters/1337box.lua

@@ -0,0 +1,15 @@
+function GetFileName(fullpath)
+  extension = fullpath:match("[^.]*$")
+  file = string.gsub(fullpath,"." .. extension,"_orig." .. extension)
+  return file
+end
+
+-- Generate correct html syntax with path to image
+function make_lightbox (path)
+ return '<img tabindex=1 src="' .. path .. '"/><img class="f" src="' .. GetFileName(path) .. '" onerror="this.onerror=null;this.src=\'' .. path .. '\'" />'
+end
+
+-- Identify all images and change format
+function Image (elem)
+ return pandoc.RawInline('html', make_lightbox(elem.src))
+end

+ 2 - 0
www-example/bunnies/site/template.include

@@ -35,6 +35,8 @@ $endfor$
 </head>
 <body>
 <div class="page">
+.f{position:fixed;top:-999%;left:50%;max-height:99%;max-width:99%;transform:translate(-50%,-50%)}*:focus+*{top:50%}
+img{cursor:pointer}
 $for(include-before)$
 $include-before$
 $endfor$