Browse Source

Added missing files.

Toni Fadjukoff 12 years ago
parent
commit
a835cdbbab
7 changed files with 283 additions and 1 deletions
  1. 8 1
      .gitignore
  2. 25 0
      cgi-bin/food.cgi
  3. 28 0
      code.html
  4. 15 0
      pna.html
  5. 86 0
      ruoka.css
  6. 95 0
      ruoka.js
  7. 26 0
      todo.html

+ 8 - 1
.gitignore View File

@@ -1 +1,8 @@
1
-*.html
1
+*.temp.html
2
+1.html
3
+2.html
4
+3.html
5
+4.html
6
+5.html
7
+6.html
8
+table.html

+ 25 - 0
cgi-bin/food.cgi View File

@@ -0,0 +1,25 @@
1
+#!/usr/bin/env perl
2
+
3
+use strict;
4
+
5
+print "Content-Type: text/html; charset=iso-8859-1\n\n";
6
+
7
+print '<?xml version="1.0" encoding="iso-8859-1"?>
8
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
9
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi" lang="fi">
10
+<head>
11
+  <title>Ruokalistat</title>
12
+</head>
13
+<body>';
14
+
15
+my $min_refresh_secs = 60*5;
16
+my @st = stat("/var/www/rna/1.html");
17
+if ($st[9] > time-$min_refresh_secs) {
18
+  print "<p>Ruokalistaa on jo päivitetty alle 5min sitten.</p>";
19
+} elsif (system("cd /var/www/rna && ./food.pl") == 0) {
20
+  print "<p>Ruokalista päivitetty.</p>";
21
+} else {
22
+  print "<p>Virhe päivittäessä ruokalistaa.</p>";
23
+}
24
+
25
+print "\n<p><a href=\"/\">Takaisin</a></p>\n</body></html>\n";

+ 28 - 0
code.html View File

@@ -0,0 +1,28 @@
1
+<?xml version="1.0" encoding="iso-8859-1"?>
2
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi" lang="fi">
4
+<head>
5
+  <title>Ruokalistat</title>
6
+  <link rel="stylesheet" type="text/css" href="ruoka.css" />
7
+</head>
8
+<body>
9
+  <h1>Ruokalistakoodit</h1>
10
+
11
+  <p>
12
+    Copyright &copy; 2007-2008 <a href="http://iki.fi/tss/">Timo Sirainen</a>, 2011-2012 Toni Fadjukoff<br />
13
+    Lisenssinä Public Domain, eli tehkää mitä lystää näillä.<br />
14
+  </p>
15
+  <ul>
16
+    <li><a href="food.pl">food.pl</a> - Pääskripti, testatessa on hyvä asettaa $use_old=1</li>
17
+    <li><a href="juvenes.pl">juvenes.pl</a> - Juveneksen parsinta</li>
18
+    <li><a href="amica.pl">amica.pl</a> - Amican parsinta</li>
19
+    <li><a href="pky.pl">pky.pl</a> - PKY:n parsinta</li>
20
+    <li><a href="sodexo.pl">sodexo.pl</a> - Sodexo:n parsinta</li>
21
+    <li><a href="ruoka.css">ruoka.css</a> - CSS</li>
22
+    <li><a href="ruoka.js">ruoka.js</a> - Javascriptin staattinen osuus</li>
23
+    <li><a href="food.pl">food.cgi</a> - CGI-skripti ruokalistan päivitykseen</li>
24
+  </ul>
25
+  <p>Katso myös <a href="todo.html">TODO</a> lista.</p>
26
+  <p><a href="http://git.lamperi.name/pna.git/">Git-repo saatavilla</a></p>
27
+</body>
28
+</html>

+ 15 - 0
pna.html View File

@@ -0,0 +1,15 @@
1
+<?xml version="1.0" encoding="iso-8859-1"?>
2
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi" lang="fi">
4
+<head>
5
+  <title>RNA</title>
6
+</head>
7
+<body>
8
+
9
+<p><!--<img src="rna.gif" alt="RNA" /><br />-->
10
+Se o <s><a href="http://en.wikipedia.org/wiki/Ribonucleic_acid">ribonucleic
11
+acid</a></s> <a href="http://en.wikipedia.org/wiki/Peptide_nucleic_acid">peptide
12
+nucleic acid</a>.</p>
13
+
14
+</body>
15
+</html>

+ 86 - 0
ruoka.css View File

@@ -0,0 +1,86 @@
1
+div.foods {
2
+	border-style: dotted none none none;
3
+	border-width: 2px;
4
+	margin-top: 0.5em;
5
+}
6
+
7
+div.left {
8
+	border-style: none dotted none none;
9
+	border-width: 2px;
10
+	margin-right: 2em;
11
+	float: left;
12
+	width: 34%;
13
+}
14
+
15
+div.right {
16
+	border-style: none none none dotted;
17
+	border-width: 2px;
18
+	padding-left: 1em;
19
+	float: right;
20
+	width: 34%;
21
+}
22
+
23
+div.middle {
24
+	margin-left: 34%;
25
+	margin-right: 34%;
26
+}
27
+
28
+div.middle h2 {
29
+	position: relative;
30
+	left: -1.5em;
31
+}
32
+
33
+h1 {
34
+	font-size: 120%;
35
+        margin: 0px;
36
+	padding: 0px;
37
+}
38
+
39
+h2 {
40
+	font-weight: bold;
41
+	font-size: 110%;
42
+	text-decoration: underline;
43
+	margin: 0px;
44
+}
45
+
46
+ul {
47
+	margin-top: 0px;
48
+	margin-bottom: 0.3em;
49
+}
50
+
51
+a {
52
+	color: #007000;
53
+	text-decoration: underline;
54
+}
55
+
56
+div.title {
57
+	font-size: 80%;
58
+}
59
+div.title span.days {
60
+	padding-right: 2em;
61
+}
62
+div.title span.location {
63
+	padding-left: 2em;
64
+}
65
+
66
+div.foods span.allergy {
67
+	font-size: 80%;
68
+}
69
+
70
+div.footer {
71
+	clear: both;
72
+	font-size: 80%;
73
+	width: 100%;
74
+	border-style: solid none none none;
75
+	border-width: 1px;
76
+}
77
+
78
+.missing {
79
+	font-size: 80%;
80
+}
81
+
82
+.nextweek {
83
+	font-size: 80%;
84
+	font-weight: bold;
85
+	margin: 0.5em;
86
+}

+ 95 - 0
ruoka.js View File

@@ -0,0 +1,95 @@
1
+function is_in_list(list, num) {
2
+  for (i = 0; i < list.length; i++) {
3
+    if (list[i] == num)
4
+      return true;
5
+  }
6
+  return false;
7
+}
8
+
9
+function any_allergies_set()
10
+{
11
+  for (a = 0; a < allergies.length; a++) {
12
+    var e = document.getElementById("allergy_" + allergies[a]);
13
+    if (e.checked)
14
+      return true;
15
+  }
16
+  return false;
17
+}
18
+
19
+function unhighlight() {
20
+  for (f = 0; f < food_count; f++) {
21
+    var e = document.getElementById("f"+f);
22
+    e.style.background = "#ffffff";
23
+  }
24
+}
25
+
26
+function fix_hrefs() {
27
+  // change all links to submit-buttons
28
+  for (f = 0; f < document.links.length; f++) {
29
+    var href = document.links[f].href;
30
+    var i = href.lastIndexOf('/') + 1;
31
+    if (href[i] >= '1' && href[i] <= '7' && href[i+1] == '.') {
32
+      document.links[f].onclick = function() {
33
+	document.forms[0].action = this.href;
34
+	document.forms[0].submit();
35
+	return false;
36
+      }
37
+    }
38
+  }
39
+}
40
+
41
+function highlight() {
42
+  fix_hrefs();
43
+  if (!any_allergies_set()) {
44
+    unhighlight();
45
+    return;
46
+  }
47
+
48
+  for (f = 0; f < food_count; f++) {
49
+    var eatable = 1;
50
+    for (a = 0; a < allergies.length; a++) {
51
+      var e = document.getElementById("allergy_" + allergies[a]);
52
+      if (e.checked) {
53
+	if (is_in_list(eatable_foods[allergies[a]], f)) {
54
+	  // still (maybe) eatable
55
+	} else if (is_in_list(maybe_eatable_foods[allergies[a]], f)) {
56
+	  // just maybe eatable
57
+	  eatable = 0;
58
+	} else {
59
+	  eatable = -1;
60
+	}
61
+      }
62
+    }
63
+    var e = document.getElementById("f"+f);
64
+    if (eatable < 0) {
65
+      e.style.background = "#ffffff";
66
+      //e.style.display = "none";
67
+    } else {
68
+      //e.style.display = "list-item";
69
+      e.style.background = eatable > 0 ? "#ffff00" : "#cccccc";
70
+    }
71
+  }
72
+}
73
+
74
+function url_param(name)
75
+{
76
+  // From http://www.netlobo.com/url_query_string_javascript.html
77
+  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
78
+  var regexS = "[\\?&]"+name+"=([^&#]*)";
79
+  var regex = new RegExp( regexS );
80
+  var results = regex.exec( window.location.href );
81
+  if( results == null )
82
+    return "";
83
+  else
84
+    return results[1];
85
+}
86
+
87
+function set_allergies()
88
+{
89
+  for (a = 0; a < allergies.length; a++) {
90
+    var e = document.getElementById("allergy_" + allergies[a]);
91
+    if (url_param("allergy_" + allergies[a]) != "")
92
+      e.checked = true;
93
+  }
94
+  highlight();
95
+}

+ 26 - 0
todo.html View File

@@ -0,0 +1,26 @@
1
+<?xml version="1.0" encoding="iso-8859-1"?>
2
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi" lang="fi">
4
+<head>
5
+  <title>TODO</title>
6
+  <link rel="stylesheet" type="text/css" href="ruoka.css" />
7
+</head>
8
+<body>
9
+
10
+<p><!--Itselläni ei ole aikaa/energiaa uhrata sivustolle juuri ollenkaan, mutta-->
11
+Jos jotakuta kiinnostaa, niin tässä on jotain TODO-listaa:</p>
12
+
13
+<ul>
14
+  <!-- <li>Sodexo muutti sivustojaan, joten sen parserit on nyt rikki</li>-->
15
+  <li>Uutena featurena voisi kopioida Juvenekselta info-ikkunan tiedot, eli
16
+  ruokien rasva/hiilari/proteiini/ym. tiedot.</li>
17
+  <!-- <li>Eipä tietysti haittaisi jos joku siirtäisi nämä sivut johonkin
18
+  ainejärjestön tjsp veppisivulle. En voi luvata että nämä pysyvät täällä
19
+  ikuisesti.</li>-->
20
+</ul>
21
+
22
+<p>Koodit tietysti saa <a href="code.html">täältä</a>, eli siitä vaan
23
+koodaamaan. Voin laittaa sitten päivitetyn version ajautumaan täällä.</p>
24
+
25
+</body>
26
+</html>