From 6f59b479f31eac692e49bce91618a0cf94a578e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sat, 4 Feb 2017 21:10:59 +0000 Subject: [PATCH] "view only" version --- .gitignore | 2 + www/_templates/.htaccess | 1 + www/_templates/Template.php | 31 ++++ www/_templates/front_doc_listing.php | 16 ++ www/_templates/front_doc_overview.php | 14 ++ www/_templates/front_intro.php | 5 + www/_templates/front_wrap.php | 58 +++++++ www/assets/main.css | 218 ++++++++++++++++++++++++++ www/assets/pile_white.svg | 104 ++++++++++++ www/index.php | 86 ++++++++++ 10 files changed, 535 insertions(+) create mode 100644 .gitignore create mode 100644 www/_templates/.htaccess create mode 100644 www/_templates/Template.php create mode 100644 www/_templates/front_doc_listing.php create mode 100644 www/_templates/front_doc_overview.php create mode 100644 www/_templates/front_intro.php create mode 100644 www/_templates/front_wrap.php create mode 100644 www/assets/main.css create mode 100644 www/assets/pile_white.svg create mode 100644 www/index.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0495d7d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +pile.db +vendor diff --git a/www/_templates/.htaccess b/www/_templates/.htaccess new file mode 100644 index 0000000..14249c5 --- /dev/null +++ b/www/_templates/.htaccess @@ -0,0 +1 @@ +Deny from all \ No newline at end of file diff --git a/www/_templates/Template.php b/www/_templates/Template.php new file mode 100644 index 0000000..2739e6f --- /dev/null +++ b/www/_templates/Template.php @@ -0,0 +1,31 @@ +vars[$name]; + } + + public function __set($name, $value) { + if($name == 'view_template_file') { + throw new Exception("Cannot bind variable named 'view_template_file'"); + } + $this->vars[$name] = $value; + } + + public function render($view_template_file) { + if(array_key_exists('view_template_file', $this->vars)) { + throw new Exception("Cannot bind variable called 'view_template_file'"); + } + extract($this->vars); + ob_start(); + include($view_template_file); + return ob_get_clean(); + } +} + +?> \ No newline at end of file diff --git a/www/_templates/front_doc_listing.php b/www/_templates/front_doc_listing.php new file mode 100644 index 0000000..dbdefc4 --- /dev/null +++ b/www/_templates/front_doc_listing.php @@ -0,0 +1,16 @@ +
+

+

+
+ + +
+ ">🔗 + "> +
+

+

+
+
+
+ \ No newline at end of file diff --git a/www/_templates/front_doc_overview.php b/www/_templates/front_doc_overview.php new file mode 100644 index 0000000..aa2001e --- /dev/null +++ b/www/_templates/front_doc_overview.php @@ -0,0 +1,14 @@ +
+

+

+

Published:

+

Tags: + " . $tag["Name"] . ""; + } + ?> +

+

Description:

+ +
\ No newline at end of file diff --git a/www/_templates/front_intro.php b/www/_templates/front_intro.php new file mode 100644 index 0000000..74853a5 --- /dev/null +++ b/www/_templates/front_intro.php @@ -0,0 +1,5 @@ +
+

This site is the sdbs pile, where we upload the stuff we consider important to the larger conceptual and thematic landscape of what we do: "confronting apathy", inter-subjectivity, the human right to self-determination, counter-culture and such...

+

Tohle je hromádka zajímavýho materiálu co něco znamená v kontextu sdbs - budeme sem postupně dávat ty nejdůležitější nebo nejzajímavější věci, zatim se o tom ale nikde moc nešiřte.

+

/-\

+
\ No newline at end of file diff --git a/www/_templates/front_wrap.php b/www/_templates/front_wrap.php new file mode 100644 index 0000000..b28cbfe --- /dev/null +++ b/www/_templates/front_wrap.php @@ -0,0 +1,58 @@ + + + + + + + + The /-\ pile + + + + + + + + + + + + +
+ +
+ +
+
+ + + +
+
+ + \ No newline at end of file diff --git a/www/assets/main.css b/www/assets/main.css new file mode 100644 index 0000000..dbfafc4 --- /dev/null +++ b/www/assets/main.css @@ -0,0 +1,218 @@ +@font-face { + font-family: Prociono; + src: url(Prociono.woff); +} + +*, *:before, *:after { + -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; +} + +body { + font-family: Prociono; + margin: 0; + padding: 0; + position: relative; + height: 100%; + background: #f2f2f2; +} + +a { + color: #f2f2f2; + text-decoration: none; +} + +#sidebar { + font-family: Prociono, serif; +} + +#sidebar-head { + background-color: #202020; + color: white; + + background-image: url(/assets/pile_white.svg); + background-repeat: no-repeat; + background-position: center 1.5em; + background-size: 50%; + + text-align: center; +} + +#sidebar-head > h1 { + padding: 0.5em; + padding-top: 6em; + margin: 0; + margin-bottom: 1rem; +} + +#sidebar-taglist { + background: #202020; + color: #f2f2f2; + padding: 1rem 0 1rem 0; +} + +#sidebar-taglist > ul > li { + list-style: none; + font-size: 14pt; + margin-bottom: .5em; +} + +#sidebar-taglist > ul > li:before { + content: "/ "; +} + +#sidebar-taglist-top:before { + content: "\\ " !important; +} + +#sidebar-taglist a { + color: #f2f2f2; + text-decoration: none; +} + +#content { + font-size: 14pt; +} + +.text { + background: #202020; + color: #f2f2f2; + padding: 1rem; + margin: 0 0 1rem 0; +} + +.doc-item-text { + display: inline-block; + margin-right: 3em; +} + +.doc-item h2 { + font-size: 14pt; + font-weight: normal; + margin: 0; +} + +.doc-item h3 { + margin: 0; + font-size: 11pt; + font-weight: normal; + font-style: italic; +} + +.doc-item-link { + display: inline-block; + font-size: 18pt; + font-weight: bold; + float: right; + position: relative; + top: 7px; + right: 1em; +} + +.tag-text + +.document h1 { + margin: 0; + font-size: 24pt; +} + +.document h2 { + margin: 2pt 0 2pt 0; + font-style: italic; + font-weight: normal; + font-size: 16pt; +} + +.document h3 { + margin: 2pt 0 2pt 0; + font-weight: normal; + font-size: 16pt; +} + +.doc-taglist li { + list-style: none; + display: inline-block; +} + +.doc-taglist li a { + text-decoration: underline; +} + +.doc-taglist li:after { + content: "/"; +} + +.doc-taglist li:last-of-type:after { + content: ""; +} + +.doc-description-intro, .doc-link-intro { + font-weight: bold; +} + +.doc-link-intro:before { + content: "➜ "; +} + +.doc-link a { + text-decoration: underline; +} + +@media screen and (min-width: 64em ) { + #sidebar { + position: absolute; + top: 0; + left: 2rem; + width: 14rem; + } + + #content { + margin: 2rem 2rem 0 18rem; + padding: 0 0 2rem 0; + } +} + +@media screen and (max-width: 64em ) { + #sidebar-head { + background-position: 14%; + background-size: 4rem; + height: 7rem; + margin-bottom: 1rem; + } + + #sidebar-head > h1 { + padding-top: 1.5rem; + font-size: 3rem; + } + + #sidebar-taglist { + margin-bottom: 1rem; + } +} + +#login { + position: absolute; + bottom: 0; + right: 2rem; +} + +#login input { + height: 14pt; + border: 1px solid lightgray; +} + +#login button { + height: 14pt; + font-size: 8pt; + border: 1px solid lightgray; + background: white; +} + +.czech { + font-size: 12pt; +} + +.sign { + font-weight: bold; + font-size: 16pt; + margin: 0; +} \ No newline at end of file diff --git a/www/assets/pile_white.svg b/www/assets/pile_white.svg new file mode 100644 index 0000000..2bd67fc --- /dev/null +++ b/www/assets/pile_white.svg @@ -0,0 +1,104 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/www/index.php b/www/index.php new file mode 100644 index 0000000..eb353f1 --- /dev/null +++ b/www/index.php @@ -0,0 +1,86 @@ +query("SELECT count(ID) FROM Documents")->fetchArray(SQLITE3_NUM); +$count = $ret_count[0]; + +$tag_query = "SELECT + ID, Name, count(Document) + FROM + Tags t + LEFT OUTER JOIN + DocumentstoTags d ON t.ID = d.Tag + GROUP BY Name + ORDER BY count(Document) DESC, Name"; +$tags_ret = $db->query($tag_query); +$tags = []; +while ($row = $tags_ret->fetchArray(SQLITE3_NUM)) { + array_push($tags, array( + 'href' => $row[0], + 'name' => $row[1], + 'count' => $row[2] + )); +} + +if (isset($_GET["item"])) { + $stmt_doc = $db->prepare("SELECT * FROM Documents WHERE ID = :id"); + $stmt_doc->bindValue(":id", $_GET["item"], SQLITE3_INTEGER); + $doc = $stmt_doc->execute()->fetchArray(SQLITE3_ASSOC); + + $stmt_tags = $db->prepare("SELECT t.ID, t.Name FROM Tags t + JOIN DocumentsToTags dt ON t.ID = dt.Tag + JOIN Documents d on t.ID = dt.Document + WHERE d.ID = :id"); + $stmt_tags->bindValue(":id", $_GET["item"], SQLITE3_INTEGER); + $ret = $stmt_tags->execute(); + $doc_tags = []; + while ($tag = $ret->fetchArray(SQLITE3_ASSOC)) { + array_push($doc_tags, $tag); + } + + $doc_template = new Template(); + $doc_template->doc = $doc; + $doc_template->tags = $doc_tags; + $content = $doc_template->render('front_doc_overview.php'); +} elseif (isset($_GET["tag"])) { + if ($_GET["tag"] == "*"){ + $query = "SELECT ID, Title, Author, Published, URL FROM Documents"; + $doc_ret = $db->query($query); + } else { + $stmt = $db->prepare("SELECT + ID, Title, Author, Published, URL + FROM + Documents d + LEFT OUTER JOIN + DocumentsToTags t ON d.ID = t.Document + WHERE Tag == :tag"); + $stmt->bindValue(":tag", $_GET["tag"], SQLITE3_INTEGER); + $doc_ret = $stmt->execute(); + } + $docs = []; + while ($doc = $doc_ret->fetchArray(SQLITE3_ASSOC)) { + $doc['date'] = empty($doc["Published"]) ? "" : "(" . $doc["Published"] . ")"; + array_push($docs, $doc); + } + + $stmt = $db->prepare("SELECT Name, Description FROM Tags WHERE ID == :tag"); + $stmt->bindValue(":tag", $_GET["tag"], SQLITE3_INTEGER); + + $doc_list_template = new Template(); + $doc_list_template->tag = $stmt->execute()->fetchArray(SQLITE3_ASSOC); + $doc_list_template->docs = $docs; + $content = $doc_list_template->render('front_doc_listing.php'); +} else { + $intro_template = new Template(); + $content = $intro_template->render('front_intro.php'); +} + +$page = new Template(); +$page->tag_count = $count; +$page->tags = $tags; +$page->content = $content; +echo $page->render('front_wrap.php'); +?> \ No newline at end of file