summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO11
-rw-r--r--bsd.rc3
-rw-r--r--lunix.rc3
-rw-r--r--lupin/anmeldelse.lua22
-rw-r--r--lupin/artikkel.lua18
-rwxr-xr-xtears13
-rwxr-xr-xtears.cgi222
-rw-r--r--tears.css193
-rw-r--r--tears.js42
9 files changed, 527 insertions, 0 deletions
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..0230426
--- /dev/null
+++ b/TODO
@@ -0,0 +1,11 @@
+Med en gang:
+ > Forside
+ > Tags (tvang!)
+ > Lupin må kunne brukes som lua-bibliotek
+ > Skille mellom gamle og nye artikler
+ > Templates til lupin (artikkel, anmeldelse, reprise / sending, om redaksjon)
+ > Oversiktssider
+
+I kyberfremtiden:
+ > AI <3
+
diff --git a/bsd.rc b/bsd.rc
new file mode 100644
index 0000000..417ae96
--- /dev/null
+++ b/bsd.rc
@@ -0,0 +1,3 @@
+byline() {
+ stat -f '%Su' $1
+}
diff --git a/lunix.rc b/lunix.rc
new file mode 100644
index 0000000..308bc0f
--- /dev/null
+++ b/lunix.rc
@@ -0,0 +1,3 @@
+byline() {
+ stat -c 'skrevet av %U for %G' $1
+}
diff --git a/lupin/anmeldelse.lua b/lupin/anmeldelse.lua
new file mode 100644
index 0000000..37a441b
--- /dev/null
+++ b/lupin/anmeldelse.lua
@@ -0,0 +1,22 @@
+local artikkel = blueprint("anmeldelse")
+
+function artikkel.env(data)
+ data.terningkast = os.getenv("POST_terningkast") or ""
+ data.publisert = os.getenv("POST_publisert") or ""
+end
+
+function artikkel.form(body, data)
+ html.p()
+ html.label("Overskrift:")
+ html.text('title', data.title, 32)
+ html.p()
+ html.label("Terningkast:")
+ html.p(data.terningkast)
+ html.select('terningkast', { 1, 2, 3, 4, 5, 6 }, data.terningkast or 1)
+ html.p()
+ html.textarea('tekst', body)
+ html.hidden('type', 'anmeldelse')
+end
+
+return artikkel
+
diff --git a/lupin/artikkel.lua b/lupin/artikkel.lua
new file mode 100644
index 0000000..3ad2f4d
--- /dev/null
+++ b/lupin/artikkel.lua
@@ -0,0 +1,18 @@
+local artikkel = blueprint("default")
+
+function artikkel.env(data)
+ data.bilde = os.getenv("POST_bilde")
+ data.publisert = os.getenv("POST_publisert")
+end
+
+function artikkel.form(body, data)
+ html.p()
+ html.label("Overskrift:")
+ html.text('title', data.title, 32)
+ html.orz('bilde', data.bilde or '')
+ html.p()
+ html.textarea('tekst', body)
+end
+
+return artikkel
+
diff --git a/tears b/tears
new file mode 100755
index 0000000..cf46689
--- /dev/null
+++ b/tears
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+LINKS="ditt gruppe lagre oppdater rediger skriv teatime todo"
+
+case $1 in
+ prepare)
+ for link in $LINKS; do
+ ln -s index.html "$link"
+ done
+ ;;
+ '') echo "$0 [-h] command";;
+esac
+
diff --git a/tears.cgi b/tears.cgi
new file mode 100755
index 0000000..6698f07
--- /dev/null
+++ b/tears.cgi
@@ -0,0 +1,222 @@
+#!/usr/local/bin/haserl --shell=/bin/bash
+
+<%
+
+VERSION=0.1
+BASE="/~bie/tears"
+HOST="low.radionova.no"
+
+path=$(pdecode <<<"${PATH_INFO#/}")
+
+error() {
+ echo -e "Content-Type: text/plain; charset=utf-8\n"
+ echo "$1"
+ exit 1
+}
+
+irc() {
+ teatime -c '#radionova' "$1"
+}
+
+byline() {
+ echo # noe som fungerer både på lunix og bsd her
+}
+
+info() {
+ stat -c '%n: %U %G %a %Y' $1
+}
+
+link() {
+ [ "$BASE/$2" = $REQUEST_URI ] && echo "$1" || echo "<a href='$BASE/$2'>$1</a>"
+}
+
+qlink() {
+ text="$1" && url="$BASE/$2" && shift 2
+ IFS=\& && echo -n "<a href='$url?$*'>$text</a>"
+}
+
+redirect() {
+ echo "Content-Type: text/html"
+ echo -e "Location: https://$HOST$1\n"
+ echo "٩(͡๏̯͡๏)۶>"
+}
+
+kalender() {
+ [ "$action" = index.html -o "$action" = ditt -o "$action" = gruppe ] || return
+ echo "<p><b>for mye? reis i tid…</b>"
+ IFS=- read y m d <<<"$GET_dato"
+ if [ -z "$y" ]; then
+ for directory in $(cut -d / -f 2 | sort | uniq); do
+ year=$(basename $directory)
+ echo "<a href='?dato=$year'>$year</a>"
+ done
+ elif [ -z "$m" ]; then
+ echo "<b><a href='?'>$y</a></del></b><br>"
+ for directory in $(cut -d / -f 3 | sort | uniq); do
+ month=$(basename $directory)
+ echo "<a href='?dato=$y-$month'>$month</a>"
+ done
+ elif [ -z "$d" ]; then
+ echo "<b><a href='?'>$y</a>/<a href='?dato=$y'>$m</a></b><br>"
+ for directory in $(cut -d / -f 4 | sort | uniq); do
+ day=$(basename $directory)
+ echo "<a href='?dato=$y-$m-$day'>$day</a>"
+ done
+ else
+ echo "<b><a href='?'>$y</a>/<a href='?dato=$y'>$m</a>/<a href='?dato=$y-$m'>$d</a></b>"
+ fi
+}
+
+meny() {
+ echo -e "Content-Type: text/html; charset=utf-8\n"
+ echo "<!doctype html>"
+ echo "<title>tears</title>"
+ echo "<link href=$BASE/tears.css rel=stylesheet>"
+ echo "<script src=$BASE/tears.js></script>"
+ echo "<div id='meny'>"
+ link "<pre>$(figlet -f threepoint tears)</pre>" ""
+ echo "<p><b>hei, $(whoami) &hearts;</b><br>"
+ link 'skriv en artikkel' 'skriv'
+ echo "<p><b>du har tilgang til…</b><br>"
+ link 'dine artikler' 'ditt' && echo "<br>"
+ for group in $available; do
+ link "$group" "gruppe/$group"
+ done
+ kalender
+ echo "<p><b>kos deg! ٩(͡๏̯͡๏)۶</b>"
+ echo "<p class=footer><b>tears $VERSION</b><br>"
+ link 'todo' 'todo' && echo '|' && link 'teatime' 'teatime'
+ echo "</div>"
+}
+
+liste() {
+ n=$((${GET_n:-0} + 7))
+ $finder -printf '%h\t%TT\t%f\n' | sort -r | head -$n | tail -7 | while read
+ do
+ d=$(cut -f 1 <<<"$REPLY")
+ f=$(cut -f 3 <<<"$REPLY")
+ kort $d/$f
+ done
+ echo "<hr><p>"
+ qlink "eldre artikler…" "$action/$path" "dato=$GET_dato" "n=$n"
+}
+
+tags() {
+ find -L tags -samefile "$1" -execdir dirname {} + | while read file; do
+ echo -n "${file##*/} "
+ done
+
+ # tag "$1" "$POST_tags"
+}
+
+tag() {
+ echo "<p>"
+ for tag in $2; do
+ echo "-- sjekke om tag $tag er ok --"
+ echo "<br>"
+ echo ln -s "$1" "tags/$tag/$(tr / - <<<$1)"
+ echo "<br>"
+ done
+}
+
+skjema() {
+ [ ! -f "$1" ] && echo "<p>finner ikke $1: <pre>$(xxd <<<$1)</pre>" && exit
+ [ ! -w "$1" ] && echo "<p>du har ikke skrivetilgang" && exit
+ echo "<form method='post' action='$BASE/oppdater/$1'>"
+ lupin -f <$1
+ echo "<p><label>Magiske ord:</label>"
+ echo "<input type='text' name='tags' value='$(tags $1)'>"
+ tag "$1" "ok test haha"
+ echo "<p><input type='submit' value='Lagre'>"
+ echo "</form>"
+ echo "<p><b>$(info $1)</b>"
+}
+
+vis() {
+ [ ! -f "$1" ] && echo "<p>finner ikke $1: <pre>$(xxd <<<$1)</pre>" && exit
+ [ ! -r "$1" ] && echo "<p>du har ikke lesetilgang" && exit
+ lupin -h <$1
+}
+
+lagre() {
+ path=$(date +%Y/%m/%d -d $POST_publisert)
+ slug=$(sed -e 's|[ /]|-|g' -e 's|[?:]||g' <<<$POST_title)
+ [ -z "$slug" ] && error "Ugyldig overskrift"
+ [ -f "artikler/$path/$slug.txt" ] && error "Artikkelen finnes allerede"
+ mkdir -m 777 -p "artikler/$path"
+ [ -z "$POST_privat" ] && umask 0002
+ lupin -l -e >"artikler/$path/$slug.txt"
+ chgrp $POST_gruppe "artikler/$path/$slug.txt"
+ irc "$(whoami) skriver ny artikkel: $POST_title"
+ redirect "$BASE/rediger/artikler/$path/$slug.txt"
+}
+
+oppdater() {
+ [ ! -f "$1" ] && error "finner ikke $1"
+ [ ! -w "$1" ] && error "ikke skrivetilgang til $1"
+ [ -z "$POST_title" ] && error "ingen overskrift"
+ lupin -l -e >$1
+ irc "$(whoami) redigerte $POST_title"
+ redirect "$BASE/rediger/$path"
+}
+
+kort() {
+ IFS=/. read -r type y m d hhmm slug ext <<< "$1"
+ (
+ read -r tittel
+ echo "<h2>$tittel</h2>" "<p class='x'>$(byline $1), $y/$m/$d"
+ [ -r "$1" ] && echo "·" && link "vis" $(pencode / <<<"vis/$1")
+ [ -w "$1" ] && echo "·" && link "rediger" $(pencode / <<<"rediger/$1")
+ [ -z "$2" ] && head -1 | marxup - || marxup -
+ ) < $1
+}
+
+forbered() {
+ echo "<form method=post action='$BASE/lagre/$path'>"
+ echo "<p><label>Overskrift:</label>"
+ echo "<input type=text name=title size=24>"
+ echo "<p><label>Dato:</label>"
+ echo "<input type=date name=publisert value=$(date +%Y-%m-%d) size=10>"
+ echo "<p><label>*</label>"
+ echo "<select name='type'>"
+ for type in lupin/*; do
+ id=$(basename $type .lua)
+ echo "<option value='$id'>$(sed 's|.|\U&|' <<<$id)</option>"
+ done
+ echo "</select>"
+ echo "for"
+ echo "<select name=gruppe>"
+ for group in $available; do
+ echo "<option>$group</option>"
+ done
+ echo "</select>"
+ echo "(<input type=checkbox name=privat>privat artikkel?)"
+ echo "<p><label>*</label><input type=submit value='Forbered artikkel...'>"
+ echo "</form>"
+}
+
+[ -f tears.rc ] && . tears.rc
+
+umask 0022
+
+groups=$(groups | tr " " "\n" | sort)
+available=$(comm -12 - <(ls redaksjoner | sort) <<<"$groups")
+action=$(basename $SCRIPT_FILENAME)
+kilde="artikler/$(sed 's|-|/|g' <<<$GET_dato)"
+finder="find $kilde -type f"
+[ "$action" = gruppe ] && finder="$finder -group $path"
+[ "$action" = ditt ] && finder="$finder -user $REMOTE_USER"
+[ "$REQUEST_METHOD" = GET ] && $finder | meny
+case $action in
+ index.html|ditt|gruppe) liste;;
+ skriv) forbered;;
+ rediger) skjema $path;;
+ vis) vis $path;;
+ lagre) lagre;;
+ oppdater) oppdater $path;;
+ teatime) irc "$(whoami) <3 teatime"; echo "<p><img src='http://atei.st/src/1352063360909860.jpg'><br>";;
+ spökvåningen) echo "<p>spök";;
+ todo) echo "<pre>$(cat TODO)</pre>";;
+esac
+%>
+
diff --git a/tears.css b/tears.css
new file mode 100644
index 0000000..68bf86c
--- /dev/null
+++ b/tears.css
@@ -0,0 +1,193 @@
+body { font: 16px/1.4 sans-serif; }
+
+html, body { background: #eee; color: #000; }
+body { left: 240px; position: relative; max-width: 900px; margin-top: 6em; }
+form, select, textarea, input { font: inherit; }
+textarea { width: 100%; }
+div#meny { position: fixed; left: 0; top: 0; width: 180px; height: 100%; }
+div#meny { border-right: 1px dotted Tomato; padding: 0 1em; }
+div#meny { background: #fff; overflow: auto; }
+div#meny b a:hover { text-decoration: line-through; }
+h2 { margin-bottom: 0; font-size: large; }
+p.x { margin-top: 0; font-size: small; }
+p.x a { text-align: right; }
+.footer { position: absolute; bottom: 0; font-size: small; }
+pre { font-weight: bold; }
+a { text-decoration: none; color: DarkOrange; }
+a:hover, a:visited { color: Tomato; }
+img { border: 1px solid #000; }
+pre { position: relative; }
+img.orz { width: 50px; height: 50px; display: block; }
+
+label { width: 8em; float: left; margin: 0.25em 0; }
+
+
+/*!
+ * Pikaday
+ * Copyright © 2012 David Bushell | BSD & MIT license | http://dbushell.com/
+ */
+
+.pika-single {
+ z-index: 9999;
+ display: block;
+ position: relative;
+ width: 240px;
+ padding: 8px;
+ color: #333;
+ background: #fff;
+ border: 1px solid #ccc;
+ border-bottom-color: #bbb;
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+}
+
+.pika-single.is-hidden {
+ display: none;
+}
+
+.pika-single.is-bound {
+ position: absolute;
+ box-shadow: 0 5px 15px -5px rgba(0,0,0,.5);
+}
+
+.pika-title {
+ position: relative;
+ text-align: center;
+}
+
+.pika-label {
+ display: inline-block;
+ *display: inline;
+ position: relative;
+ z-index: 9999;
+ overflow: hidden;
+ margin: 0;
+ padding: 5px 3px;
+ font-size: 14px;
+ line-height: 20px;
+ font-weight: bold;
+ background-color: #fff;
+}
+.pika-title select {
+ cursor: pointer;
+ position: absolute;
+ z-index: 9998;
+ margin: 0;
+ left: 0;
+ top: 5px;
+ opacity: 0;
+}
+
+.pika-prev,
+.pika-next {
+ display: block;
+ cursor: pointer;
+ position: relative;
+ outline: none;
+ border: 0;
+ padding: 0;
+ width: 20px;
+ height: 30px;
+ background-color: transparent;
+ background-position: center center;
+ background-repeat: no-repeat;
+ background-size: 75% 75%;
+ white-space: nowrap;
+ text-indent: 100%;
+ overflow: hidden;
+ opacity: .5;
+ *position: absolute;
+ *top: 0;
+}
+
+.pika-prev:hover,
+.pika-next:hover {
+ opacity: 1;
+}
+
+.pika-prev,
+.is-rtl .pika-next {
+ float: left;
+ background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAUklEQVR42u3VMQoAIBADQf8Pgj+OD9hG2CtONJB2ymQkKe0HbwAP0xucDiQWARITIDEBEnMgMQ8S8+AqBIl6kKgHiXqQqAeJepBo/z38J/U0uAHlaBkBl9I4GwAAAABJRU5ErkJggg==');
+ *left: 0;
+}
+
+.pika-next,
+.is-rtl .pika-prev {
+ float: right;
+ background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAU0lEQVR42u3VOwoAMAgE0dwfAnNjU26bYkBCFGwfiL9VVWoO+BJ4Gf3gtsEKKoFBNTCoCAYVwaAiGNQGMUHMkjGbgjk2mIONuXo0nC8XnCf1JXgArVIZAQh5TKYAAAAASUVORK5CYII=');
+ *right: 0;
+}
+
+.pika-prev.is-disabled,
+.pika-next.is-disabled {
+ cursor: default;
+ opacity: .2;
+}
+
+.pika-select {
+ display: inline-block;
+ *display: inline;
+}
+
+.pika-table {
+ width: 100%;
+ border-collapse: collapse;
+ border-spacing: 0;
+ border: 0;
+}
+
+.pika-table th,
+.pika-table td {
+ width: 14.285714285714286%;
+}
+
+.pika-table th {
+ color: #999;
+ font-size: 12px;
+ line-height: 25px;
+ font-weight: bold;
+ text-align: center;
+}
+
+.pika-button {
+ cursor: pointer;
+ display: block;
+ outline: none;
+ border: 0;
+ margin: 0;
+ width: 100%;
+ padding: 5px;
+ color: #666;
+ font-size: 12px;
+ line-height: 15px;
+ text-align: right;
+ background: #f5f5f5;
+}
+
+.is-today .pika-button {
+ color: #33aaff;
+ font-weight: bold;
+}
+
+.is-selected .pika-button {
+ color: #fff;
+ font-weight: bold;
+ background: #33aaff;
+ box-shadow: inset 0 1px 3px #178fe5;
+ border-radius: 3px;
+}
+
+.is-disabled .pika-button {
+ pointer-events: none;
+ cursor: default;
+ color: #999;
+ opacity: .3;
+}
+
+.pika-button:hover {
+ color: #fff !important;
+ background: #ff8000 !important;
+ box-shadow: none !important;
+ border-radius: 3px !important;
+}
+
diff --git a/tears.js b/tears.js
new file mode 100644
index 0000000..fd29a3a
--- /dev/null
+++ b/tears.js
@@ -0,0 +1,42 @@
+// moment.js
+// // version : 1.7.2
+// // author : Tim Wood
+// // license : MIT
+// // momentjs.com
+(function(a){function E(a,b,c,d){var e=c.lang();return e[a].call?e[a](c,d):e[a][b]}function F(a,b){return function(c){return K(a.call(this,c),b)}}function G(a){return function(b){var c=a.call(this,b);return c+this.lang().ordinal(c)}}function H(a,b,c){this._d=a,this._isUTC=!!b,this._a=a._a||null,this._lang=c||!1}function I(a){var b=this._data={},c=a.years||a.y||0,d=a.months||a.M||0,e=a.weeks||a.w||0,f=a.days||a.d||0,g=a.hours||a.h||0,h=a.minutes||a.m||0,i=a.seconds||a.s||0,j=a.milliseconds||a.ms||0;this._milliseconds=j+i*1e3+h*6e4+g*36e5,this._days=f+e*7,this._months=d+c*12,b.milliseconds=j%1e3,i+=J(j/1e3),b.seconds=i%60,h+=J(i/60),b.minutes=h%60,g+=J(h/60),b.hours=g%24,f+=J(g/24),f+=e*7,b.days=f%30,d+=J(f/30),b.months=d%12,c+=J(d/12),b.years=c,this._lang=!1}function J(a){return a<0?Math.ceil(a):Math.floor(a)}function K(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function L(a,b,c){var d=b._milliseconds,e=b._days,f=b._months,g;d&&a._d.setTime(+a+d*c),e&&a.date(a.date()+e*c),f&&(g=a.date(),a.date(1).month(a.month()+f*c).date(Math.min(g,a.daysInMonth())))}function M(a){return Object.prototype.toString.call(a)==="[object Array]"}function N(a,b){var c=Math.min(a.length,b.length),d=Math.abs(a.length-b.length),e=0,f;for(f=0;f<c;f++)~~a[f]!==~~b[f]&&e++;return e+d}function O(a,b,c,d){var e,f,g=[];for(e=0;e<7;e++)g[e]=a[e]=a[e]==null?e===2?1:0:a[e];return a[7]=g[7]=b,a[8]!=null&&(g[8]=a[8]),a[3]+=c||0,a[4]+=d||0,f=new Date(0),b?(f.setUTCFullYear(a[0],a[1],a[2]),f.setUTCHours(a[3],a[4],a[5],a[6])):(f.setFullYear(a[0],a[1],a[2]),f.setHours(a[3],a[4],a[5],a[6])),f._a=g,f}function P(a,c){var d,e,g=[];!c&&h&&(c=require("./lang/"+a));for(d=0;d<i.length;d++)c[i[d]]=c[i[d]]||f.en[i[d]];for(d=0;d<12;d++)e=b([2e3,d]),g[d]=new RegExp("^"+(c.months[d]||c.months(e,""))+"|^"+(c.monthsShort[d]||c.monthsShort(e,"")).replace(".",""),"i");return c.monthsParse=c.monthsParse||g,f[a]=c,c}function Q(a){var c=typeof a=="string"&&a||a&&a._lang||null;return c?f[c]||P(c):b}function R(a){return a.match(/\[.*\]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function S(a){var b=a.match(k),c,d;for(c=0,d=b.length;c<d;c++)D[b[c]]?b[c]=D[b[c]]:b[c]=R(b[c]);return function(e){var f="";for(c=0;c<d;c++)f+=typeof b[c].call=="function"?b[c].call(e,a):b[c];return f}}function T(a,b){function d(b){return a.lang().longDateFormat[b]||b}var c=5;while(c--&&l.test(b))b=b.replace(l,d);return A[b]||(A[b]=S(b)),A[b](a)}function U(a){switch(a){case"DDDD":return p;case"YYYY":return q;case"S":case"SS":case"SSS":case"DDD":return o;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":case"a":case"A":return r;case"Z":case"ZZ":return s;case"T":return t;case"MM":case"DD":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return n;default:return new RegExp(a.replace("\\",""))}}function V(a,b,c,d){var e,f;switch(a){case"M":case"MM":c[1]=b==null?0:~~b-1;break;case"MMM":case"MMMM":for(e=0;e<12;e++)if(Q().monthsParse[e].test(b)){c[1]=e,f=!0;break}f||(c[8]=!1);break;case"D":case"DD":case"DDD":case"DDDD":b!=null&&(c[2]=~~b);break;case"YY":c[0]=~~b+(~~b>70?1900:2e3);break;case"YYYY":c[0]=~~Math.abs(b);break;case"a":case"A":d.isPm=(b+"").toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":c[3]=~~b;break;case"m":case"mm":c[4]=~~b;break;case"s":case"ss":c[5]=~~b;break;case"S":case"SS":case"SSS":c[6]=~~(("0."+b)*1e3);break;case"Z":case"ZZ":d.isUTC=!0,e=(b+"").match(x),e&&e[1]&&(d.tzh=~~e[1]),e&&e[2]&&(d.tzm=~~e[2]),e&&e[0]==="+"&&(d.tzh=-d.tzh,d.tzm=-d.tzm)}b==null&&(c[8]=!1)}function W(a,b){var c=[0,0,1,0,0,0,0],d={tzh:0,tzm:0},e=b.match(k),f,g;for(f=0;f<e.length;f++)g=(U(e[f]).exec(a)||[])[0],g&&(a=a.slice(a.indexOf(g)+g.length)),D[e[f]]&&V(e[f],g,c,d);return d.isPm&&c[3]<12&&(c[3]+=12),d.isPm===!1&&c[3]===12&&(c[3]=0),O(c,d.isUTC,d.tzh,d.tzm)}function X(a,b){var c,d=a.match(m)||[],e,f=99,g,h,i;for(g=0;g<b.length;g++)h=W(a,b[g]),e=T(new H(h),b[g]).match(m)||[],i=N(d,e),i<f&&(f=i,c=h);return c}function Y(a){var b="YYYY-MM-DDT",c;if(u.exec(a)){for(c=0;c<4;c++)if(w[c][1].exec(a)){b+=w[c][0];break}return s.exec(a)?W(a,b+" Z"):W(a,b)}return new Date(a)}function Z(a,b,c,d,e){var f=e.relativeTime[a];return typeof f=="function"?f(b||1,!!c,a,d):f.replace(/%d/i,b||1)}function $(a,b,c){var e=d(Math.abs(a)/1e3),f=d(e/60),g=d(f/60),h=d(g/24),i=d(h/365),j=e<45&&["s",e]||f===1&&["m"]||f<45&&["mm",f]||g===1&&["h"]||g<22&&["hh",g]||h===1&&["d"]||h<=25&&["dd",h]||h<=45&&["M"]||h<345&&["MM",d(h/30)]||i===1&&["y"]||["yy",i];return j[2]=b,j[3]=a>0,j[4]=c,Z.apply({},j)}function _(a,c){b.fn[a]=function(a){var b=this._isUTC?"UTC":"";return a!=null?(this._d["set"+b+c](a),this):this._d["get"+b+c]()}}function ab(a){b.duration.fn[a]=function(){return this._data[a]}}function bb(a,c){b.duration.fn["as"+a]=function(){return+this/c}}var b,c="1.7.2",d=Math.round,e,f={},g="en",h=typeof module!="undefined"&&module.exports,i="months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"),j=/^\/?Date\((\-?\d+)/i,k=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|.)/g,l=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?)/g,m=/([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi,n=/\d\d?/,o=/\d{1,3}/,p=/\d{3}/,q=/\d{1,4}/,r=/[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i,s=/Z|[\+\-]\d\d:?\d\d/i,t=/T/i,u=/^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,v="YYYY-MM-DDTHH:mm:ssZ",w=[["HH:mm:ss.S",/T\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/T\d\d:\d\d:\d\d/],["HH:mm",/T\d\d:\d\d/],["HH",/T\d\d/]],x=/([\+\-]|\d\d)/gi,y="Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"),z={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},A={},B="DDD w M D d".split(" "),C="M D H h m s w".split(" "),D={M:function(){return this.month()+1},MMM:function(a){return E("monthsShort",this.month(),this,a)},MMMM:function(a){return E("months",this.month(),this,a)},D:function(){return this.date()},DDD:function(){var a=new Date(this.year(),this.month(),this.date()),b=new Date(this.year(),0,1);return~~((a-b)/864e5+1.5)},d:function(){return this.day()},dd:function(a){return E("weekdaysMin",this.day(),this,a)},ddd:function(a){return E("weekdaysShort",this.day(),this,a)},dddd:function(a){return E("weekdays",this.day(),this,a)},w:function(){var a=new Date(this.year(),this.month(),this.date()-this.day()+5),b=new Date(a.getFullYear(),0,4);return~~((a-b)/864e5/7+1.5)},YY:function(){return K(this.year()%100,2)},YYYY:function(){return K(this.year(),4)},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return~~(this.milliseconds()/100)},SS:function(){return K(~~(this.milliseconds()/10),2)},SSS:function(){return K(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return a<0&&(a=-a,b="-"),b+K(~~(a/60),2)+":"+K(~~a%60,2)},ZZ:function(){var a=-this.zone(),b="+";return a<0&&(a=-a,b="-"),b+K(~~(10*a/6),4)}};while(B.length)e=B.pop(),D[e+"o"]=G(D[e]);while(C.length)e=C.pop(),D[e+e]=F(D[e],2);D.DDDD=F(D.DDD,3),b=function(c,d){if(c===null||c==="")return null;var e,f;return b.isMoment(c)?new H(new Date(+c._d),c._isUTC,c._lang):(d?M(d)?e=X(c,d):e=W(c,d):(f=j.exec(c),e=c===a?new Date:f?new Date(+f[1]):c instanceof Date?c:M(c)?O(c):typeof c=="string"?Y(c):new Date(c)),new H(e))},b.utc=function(a,c){return M(a)?new H(O(a,!0),!0):(typeof a=="string"&&!s.exec(a)&&(a+=" +0000",c&&(c+=" Z")),b(a,c).utc())},b.unix=function(a){return b(a*1e3)},b.duration=function(a,c){var d=b.isDuration(a),e=typeof a=="number",f=d?a._data:e?{}:a,g;return e&&(c?f[c]=a:f.milliseconds=a),g=new I(f),d&&(g._lang=a._lang),g},b.humanizeDuration=function(a,c,d){return b.duration(a,c===!0?null:c).humanize(c===!0?!0:d)},b.version=c,b.defaultFormat=v,b.lang=function(a,c){var d;if(!a)return g;(c||!f[a])&&P(a,c);if(f[a]){for(d=0;d<i.length;d++)b[i[d]]=f[a][i[d]];b.monthsParse=f[a].monthsParse,g=a}},b.langData=Q,b.isMoment=function(a){return a instanceof H},b.isDuration=function(a){return a instanceof I},b.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),b.fn=H.prototype={clone:function(){return b(this)},valueOf:function(){return+this._d},unix:function(){return Math.floor(+this._d/1e3)},toString:function(){return this._d.toString()},toDate:function(){return this._d},toArray:function(){var a=this;return[a.year(),a.month(),a.date(),a.hours(),a.minutes(),a.seconds(),a.milliseconds(),!!this._isUTC]},isValid:function(){return this._a?this._a[8]!=null?!!this._a[8]:!N(this._a,(this._a[7]?b.utc(this._a):b(this._a)).toArray()):!isNaN(this._d.getTime())},utc:function(){return this._isUTC=!0,this},local:function(){return this._isUTC=!1,this},format:function(a){return T(this,a?a:b.defaultFormat)},add:function(a,c){var d=c?b.duration(+c,a):b.duration(a);return L(this,d,1),this},subtract:function(a,c){var d=c?b.duration(+c,a):b.duration(a);return L(this,d,-1),this},diff:function(a,c,e){var f=this._isUTC?b(a).utc():b(a).local(),g=(this.zone()-f.zone())*6e4,h=this._d-f._d-g,i=this.year()-f.year(),j=this.month()-f.month(),k=this.date()-f.date(),l;return c==="months"?l=i*12+j+k/30:c==="years"?l=i+(j+k/30)/12:l=c==="seconds"?h/1e3:c==="minutes"?h/6e4:c==="hours"?h/36e5:c==="days"?h/864e5:c==="weeks"?h/6048e5:h,e?l:d(l)},from:function(a,c){return b.duration(this.diff(a)).lang(this._lang).humanize(!c)},fromNow:function(a){return this.from(b(),a)},calendar:function(){var a=this.diff(b().sod(),"days",!0),c=this.lang().calendar,d=c.sameElse,e=a<-6?d:a<-1?c.lastWeek:a<0?c.lastDay:a<1?c.sameDay:a<2?c.nextDay:a<7?c.nextWeek:d;return this.format(typeof e=="function"?e.apply(this):e)},isLeapYear:function(){var a=this.year();return a%4===0&&a%100!==0||a%400===0},isDST:function(){return this.zone()<b([this.year()]).zone()||this.zone()<b([this.year(),5]).zone()},day:function(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return a==null?b:this.add({d:a-b})},startOf:function(a){switch(a.replace(/s$/,"")){case"year":this.month(0);case"month":this.date(1);case"day":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return this},endOf:function(a){return this.startOf(a).add(a.replace(/s?$/,"s"),1).subtract("ms",1)},sod:function(){return this.clone().startOf("day")},eod:function(){return this.clone().endOf("day")},zone:function(){return this._isUTC?0:this._d.getTimezoneOffset()},daysInMonth:function(){return b.utc([this.year(),this.month()+1,0]).date()},lang:function(b){return b===a?Q(this):(this._lang=b,this)}};for(e=0;e<y.length;e++)_(y[e].toLowerCase(),y[e]);_("year","FullYear"),b.duration.fn=I.prototype={weeks:function(){return J(this.days()/7)},valueOf:function(){return this._milliseconds+this._days*864e5+this._months*2592e6},humanize:function(a){var b=+this,c=this.lang().relativeTime,d=$(b,!a,this.lang()),e=b<=0?c.past:c.future;return a&&(typeof e=="function"?d=e(d):d=e.replace(/%s/i,d)),d},lang:b.fn.lang};for(e in z)z.hasOwnProperty(e)&&(bb(e,z[e]),ab(e.toLowerCase()));bb("Weeks",6048e5),h&&(module.exports=b),typeof ender=="undefined"&&(this.moment=b),typeof define=="function"&&define.amd&&define("moment",[],function(){return b})}).call(this);
+
+/*!
+ * Pikaday
+ * Copyright © 2012 David Bushell | BSD & MIT license | http://dbushell.com/
+ */
+(function(e,t,n){"use strict";var r=typeof e.moment=="function",i=!!e.addEventListener,s=e.setTimeout,o=function(e,t,n,r){i?e.addEventListener(t,n,!!r):e.attachEvent("on"+t,n)},u=function(e,t,n,r){i?e.removeEventListener(t,n,!!r):e.detachEvent("on"+t,n)},a=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},f=function(e,t){return(" "+e.className+" ").indexOf(" "+t+" ")!==-1},l=function(e,t){f(e,t)||(e.className=e.className===""?t:e.className+" "+t)},c=function(e,t){e.className=a((" "+e.className+" ").replace(" "+t+" "," "))},h=function(e){return/Array/.test(Object.prototype.toString.call(e))},p=function(e){return/Date/.test(Object.prototype.toString.call(e))&&!isNaN(e.getTime())},d=function(e){return e%4===0&&e%100!==0||e%400===0},v=function(e,t){return[31,d(e)?29:28,31,30,31,30,31,31,30,31,30,31][t]},m=function(e,t){return e.getTime()===t.getTime()},g=function(e,t,r){var i,s;for(i in t){s=e[i]!==n;if(s&&typeof t[i]=="object"&&t[i].nodeName===n)p(t[i])?r&&(e[i]=new Date(t[i].getTime())):h(t[i])?r&&(e[i]=t[i].slice(0)):e[i]=g({},t[i],r);else if(r||!s)e[i]=t[i]}return e},y={field:null,bound:n,format:"YYYY-MM-DD",defaultDate:null,setDefaultDate:!1,firstDay:0,minDate:null,maxDate:null,yearRange:10,minYear:0,maxYear:9999,minMonth:n,maxMonth:n,isRTL:!1,numberOfMonths:1,i18n:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},onSelect:null,onOpen:null,onClose:null},b=function(e,t,n){t+=e.firstDay;while(t>=7)t-=7;return n?e.i18n.weekdaysShort[t]:e.i18n.weekdays[t]},w=function(e,t,n,r,i){if(i)return'<td class="is-empty"></td>';var s=[];return r&&s.push("is-disabled"),n&&s.push("is-today"),t&&s.push("is-selected"),'<td data-day="'+e+'" class="'+s.join(" ")+'"><button class="pika-button" type="button">'+e+"</button>"+"</td>"},E=function(e,t){return"<tr>"+(t?e.reverse():e).join("")+"</tr>"},S=function(e){return"<tbody>"+e.join("")+"</tbody>"},x=function(e){var t,n=[];for(t=0;t<7;t++)n.push('<th scope="col"><abbr title="'+b(e,t)+'">'+b(e,t,!0)+"</abbr></th>");return"<thead>"+(e.isRTL?n.reverse():n).join("")+"</thead>"},T=function(e){var t,n,r,i=e._o,s=e._m,o=e._y,u=o===i.minYear,a=o===i.maxYear,f='<div class="pika-title">',l=!0,c=!0;for(r=[],t=0;t<12;t++)r.push('<option value="'+t+'"'+(t===s?" selected":"")+(u&&t<i.minMonth||a&&t>i.maxMonth?"disabled":"")+">"+i.i18n.months[t]+"</option>");f+='<div class="pika-label">'+i.i18n.months[s]+'<select class="pika-select pika-select-month">'+r.join("")+"</select></div>",h(i.yearRange)?(t=i.yearRange[0],n=i.yearRange[1]+1):(t=o-i.yearRange,n=1+o+i.yearRange);for(r=[];t<n&&t<=i.maxYear;t++)t>=i.minYear&&r.push('<option value="'+t+'"'+(t===o?" selected":"")+">"+t+"</option>");return f+='<div class="pika-label">'+o+'<select class="pika-select pika-select-year">'+r.join("")+"</select></div>",u&&(s===0||i.minMonth>=s)&&(l=!1),a&&(s===11||i.maxMonth<=s)&&(c=!1),f+='<button class="pika-prev'+(l?"":" is-disabled")+'" type="button">Previous Month</button>',f+='<button class="pika-next'+(c?"":" is-disabled")+'" type="button">Next Month</button>',f+="</div>"},N=function(e,t){return'<table cellpadding="0" cellspacing="0" class="pika-table">'+x(e)+S(t)+"</table>"};e.Pikaday=function(n){var u=this,a=u.config(n);u._onMouseDown=function(t){if(!u._v)return;t=t||e.event;var n=t.target||t.srcElement;if(!n)return;if(!f(n,"is-disabled")){if(f(n,"pika-button")&&!f(n,"is-empty")){u.setDate(new Date(u._y,u._m,parseInt(n.innerHTML,10))),a.bound&&s(function(){u.hide()},100);return}f(n,"pika-prev")?u.prevMonth():f(n,"pika-next")&&u.nextMonth()}if(!f(n,"pika-select")){if(!t.preventDefault)return t.returnValue=!1;t.preventDefault()}else u._c=!0},u._onChange=function(t){t=t||e.event;var n=t.target||t.srcElement;if(!n)return;f(n,"pika-select-month")?u.gotoMonth(n.value):f(n,"pika-select-year")&&u.gotoYear(n.value)},u._onInputChange=function(t){if(r)u.setDate(e.moment(a.field.value,a.format).toDate());else{var n=new Date(Date.parse(a.field.value));u.setDate(p(n)?n:null)}u._v||u.show()},u._onInputFocus=function(e){u.show()},u._onInputClick=function(e){u.show()},u._onInputBlur=function(e){u._c||(u._b=s(function(){u.hide()},50)),u._c=!1},u._onClick=function(t){t=t||e.event;var n=t.target||t.srcElement,r=n;if(!n)return;!i&&f(n,"pika-select")&&(n.onchange||(n.setAttribute("onchange","return;"),o(n,"change",u._onChange)));do if(f(r,"pika-single"))return;while(r=r.parentNode);u._v&&n!==a.field&&u.hide()},u.el=t.createElement("div"),u.el.className="pika-single"+(a.isRTL?" is-rtl":""),o(u.el,"mousedown",u._onMouseDown,!0),o(u.el,"change",u._onChange),a.field&&(a.bound?t.body.appendChild(u.el):a.field.parentNode.insertBefore(u.el,a.field.nextSibling),o(a.field,"change",u._onInputChange),a.defaultDate||(r&&a.field.value?a.defaultDate=e.moment(a.field.value,a.format).toDate():a.defaultDate=new Date(Date.parse(a.field.value)),a.setDefaultDate=!0));var l=a.defaultDate;p(l)?a.setDefaultDate?u.setDate(l):u.gotoDate(l):u.gotoDate(new Date),a.bound?(this.hide(),u.el.className+=" is-bound",o(a.field,"click",u._onInputClick),o(a.field,"focus",u._onInputFocus),o(a.field,"blur",u._onInputBlur)):this.show()},e.Pikaday.prototype={config:function(e){this._o||(this._o=g({},y,!0));var t=g(this._o,e,!0);t.isRTL=!!t.isRTL,t.field=t.field&&t.field.nodeName?t.field:null,t.bound=!!(t.bound!==n?t.field&&t.bound:t.field);var r=parseInt(t.numberOfMonths,10)||1;t.numberOfMonths=r>4?4:r,p(t.minDate)||(t.minDate=!1),p(t.maxDate)||(t.maxDate=!1),t.minDate&&t.maxDate&&t.maxDate<t.minDate&&(t.maxDate=t.minDate=!1),t.minDate&&(t.minYear=t.minDate.getFullYear(),t.minMonth=t.minDate.getMonth()),t.maxDate&&(t.maxYear=t.maxDate.getFullYear(),t.maxMonth=t.maxDate.getMonth());if(h(t.yearRange)){var i=(new Date).getFullYear()-10;t.yearRange[0]=parseInt(t.yearRange[0],10)||i,t.yearRange[1]=parseInt(t.yearRange[1],10)||i}else t.yearRange=Math.abs(parseInt(t.yearRange,10))||y.yearRange,t.yearRange>100&&(t.yearRange=100);return t},toString:function(t){return p(this._d)?r?e.moment(this._d).format(t||this._o.format):this._d.toDateString():""},getMoment:function(){return r?e.moment(this._d):null},getDate:function(){return p(this._d)?new Date(this._d.getTime()):null},setDate:function(e){if(!e)return this._d=null,this.draw();typeof e=="string"&&(e=new Date(Date.parse(e)));if(!p(e))return;var t=this._o.minDate,n=this._o.maxDate;p(t)&&e<t?e=t:p(n)&&e>n&&(e=n),this._d=new Date(e.getTime()),this._d.setHours(0,0,0,0),this.gotoDate(this._d),this._o.field&&(this._o.field.value=this.toString()),typeof this._o.onSelect=="function"&&this._o.onSelect.call(this,this.getDate())},gotoDate:function(e){if(!p(e))return;this._y=e.getFullYear(),this._m=e.getMonth(),this.draw()},gotoToday:function(){this.gotoDate(new Date)},gotoMonth:function(e){isNaN(e=parseInt(e,10))||(this._m=e<0?0:e>11?11:e,this.draw())},nextMonth:function(){++this._m>11&&(this._m=0,this._y++),this.draw()},prevMonth:function(){--this._m<0&&(this._m=11,this._y--),this.draw()},gotoYear:function(e){isNaN(e)||(this._y=parseInt(e,10),this.draw())},draw:function(e){if(!this._v&&!e)return;var t=this._o,n=t.minYear,r=t.maxYear,i=t.minMonth,o=t.maxMonth;this._y<=n&&(this._y=n,!isNaN(i)&&this._m<i&&(this._m=i)),this._y>=r&&(this._y=r,!isNaN(o)&&this._m>o&&(this._m=o)),this.el.innerHTML=T(this)+this.render(this._y,this._m);if(t.bound){var u=t.field,a=u.offsetLeft,f=u.offsetTop+u.offsetHeight;while(u=u.offsetParent)a+=u.offsetLeft,f+=u.offsetTop;this.el.style.cssText="position:absolute;left:"+a+"px;top:"+f+"px;",s(function(){t.field.focus()},1)}},render:function(e,t){var n=this._o,r=new Date,i=v(e,t),s=(new Date(e,t,1)).getDay(),o=[],u=[];r.setHours(0,0,0,0),n.firstDay>0&&(s-=n.firstDay,s<0&&(s+=7));var a=i+s,f=a;while(f>7)f-=7;a+=7-f;for(var l=0,c=0;l<a;l++){var h=new Date(e,t,1+(l-s)),d=n.minDate&&h<n.minDate||n.maxDate&&h>n.maxDate,g=p(this._d)?m(h,this._d):!1,y=m(h,r),b=l<s||l>=i+s;u.push(w(1+(l-s),g,y,d,b)),++c===7&&(o.push(E(u,n.isRTL)),u=[],c=0)}return N(n,o)},isVisible:function(){return this._v},show:function(){this._v||(this._o.bound&&o(t,"click",this._onClick),c(this.el,"is-hidden"),this._v=!0,this.draw(),typeof this._o.onOpen=="function"&&this._o.onOpen.call(this))},hide:function(){var e=this._v;e!==!1&&(this._o.bound&&u(t,"click",this._onClick),this.el.style.cssText="",l(this.el,"is-hidden"),this._v=!1,e!==n&&typeof this._o.onClose=="function"&&this._o.onClose.call(this))},destroy:function(){this.hide(),u(this.el,"mousedown",this._onMouseDown,!0),u(this.el,"change",this._onChange),this._o.field&&(u(this._o.field,"change",this._onInputChange),this._o.bound&&(u(this._o.field,"click",this._onInputClick),u(this._o.field,"focus",this._onInputFocus),u(this._o.field,"blur",this._onInputBlur))),this.el.parentNode&&this.el.parentNode.removeChild(this.el)}}})(window,window.document);
+
+/* tears.js */
+var tears = {}
+
+function pick(src) {
+ if(tears.input) {
+ var name = tears.input.getAttribute("data-name");
+ var input = document.getElementsByName(name)[0];
+ tears.input.src = src;
+ input.value = src;
+ tears.input = null;
+ }
+}
+
+document.addEventListener("DOMContentLoaded", function(e) {
+ var field = document.getElementsByName('publisert')[0];
+ if(field) {
+ new Pikaday({ field: field, format: 'YYYY-MM-DD' });
+ }
+
+ var els = document.getElementsByClassName('orz');
+ for(var i=0; i < els.length; i++) {
+ els[i].onclick = function(e) {
+ tears.input = e.target;
+ window.open(e.target.getAttribute('data-uri'));
+ return false;
+ }
+ }
+}, false);
+