Now gracefully falls back to friendly URL's when javascript is disabled. Links are adjusted to anchors with javascript on page load.
notes/ are paginated with index.php and rewritten to from /notes/page/# and notes are permalinked at /notes/note_title. index.php loads exhibits from MySQL to allow for this.
notes/ are published via publish.py, and exhibits are published via publish_projects.py. THESE SCRIPTS ARE NOT SAFE - they trust user input implicitly and are chmodded 700.
mysql> show tables;
+----------------------------+
| Tables_in_dylanstestserver |
+----------------------------+
| notes |
| projects |
+----------------------------+
2 rows in set (0.00 sec)
mysql> desc notes;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| date_posted | date | NO | | NULL | |
| title | varchar(255) | NO | | NULL | |
| text | longblob | NO | | NULL | |
| url | varchar(255) | NO | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
mysql> desc projects;
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| title | varchar(255) | NO | | NULL | |
| text | longblob | NO | | NULL | |
+-------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
+++ /dev/null
-notes/*
-!notes/index.php
-!notes/notes.php
ErrorDocument 404 /404.php
RewriteEngine on
RewriteRule ^notes/page/([1-9]+)/?$ notes/index.php?page=$1 [L]
-RewriteRule ^note/([^/\.]+)/?$ notes/index.php?note=$1 [L]
-php_flag display_errors on
-php_value error_reporting 7
+RewriteRule ^notes/([^/\.]+)/?$ notes/index.php?note=$1 [L]
+RewriteRule ^notes/?$ notes/ [L]
+RewriteRule ^([^/\.]+)/?$ index.php?project=$1 [L]
(function(c){c.effects.slide=function(d){return this.queue(function(){var a=c(this),h=["position","top","left"],f=c.effects.setMode(a,d.options.mode||"show"),b=d.options.direction||"left";c.effects.save(a,h);a.show();c.effects.createWrapper(a).css({overflow:"hidden"});var g=b=="up"||b=="down"?"top":"left";b=b=="up"||b=="left"?"pos":"neg";var e=d.options.distance||(g=="top"?a.outerHeight({margin:true}):a.outerWidth({margin:true}));if(f=="show")a.css(g,b=="pos"?isNaN(e)?"-"+e:-e:e);var i={};i[g]=(f==
"show"?b=="pos"?"+=":"-=":b=="pos"?"-=":"+=")+e;a.animate(i,{queue:false,duration:d.duration,easing:d.options.easing,complete:function(){f=="hide"&&a.hide();c.effects.restore(a,h);c.effects.removeWrapper(a);d.callback&&d.callback.apply(this,arguments);a.dequeue()}})})}})(jQuery);
;$(document).ready(function() {
- $(".exhibit").hide();
- var divs = document.getElementsByTagName('div');
if(document.location.hash){
$(document.location.hash + '_').show();
}
+ $("ul#portfolio li a.tab").each(function(){
+ if (document.location.href.indexOf($(this).attr("href")) == 0) {
+ $("#" + this.attr("href")).show("slide", 600);
+ }
+ $(this).attr("href", "#" + $(this).attr("href"));
+ });
+ var divs = document.getElementsByTagName('div');
var i = 0;
$("ul#portfolio li a.tab").click(function() {
i++;
divs[i].className += (" shownDiv");
}
});
-
});
min-height:600px;
border:1px solid black;
padding:10px;
+ display:none;
}
.shownDiv {
#contact_me {
margin-top:100px;
+<<<<<<< HEAD
font-family:sans-serif;
+=======
+>>>>>>> no-javascript
}
/* reprap */
#peephow_title_2 {
font-size:3em;
+<<<<<<< HEAD
}
#peepshow_entry {
font:1.4em "lucida console";
}
+=======
+}
+
+#peepshow_entry {
+ font:1.4em "lucida console";
+}
+
+>>>>>>> no-javascript
/* readoo */
#readoo_title {
font:1.6em arial;
#i_like_pandora_entry {
font:1.4em "lucida console";
+<<<<<<< HEAD
}
/* notes */
pre {
margin-top:10px;
+=======
+>>>>>>> no-javascript
}
$(document).ready(function() {
- $(".exhibit").hide();
- var divs = document.getElementsByTagName('div');
if(document.location.hash){
$(document.location.hash + '_').show();
}
+ $("ul#portfolio li a.tab").each(function(){
+ if (document.location.href.indexOf($(this).attr("href")) == 0) {
+ $("#" + this.attr("href")).show("slide", 600);
+ }
+ $(this).attr("href", "#" + $(this).attr("href"));
+ });
+ var divs = document.getElementsByTagName('div');
var i = 0;
$("ul#portfolio li a.tab").click(function() {
i++;
divs[i].className += (" shownDiv");
}
});
-
});
<div id="content">
<div id="exhibit">
- <div class="exhibit" id="repthis_">
- <span id="reprap_entry">3D printing is a form of additive
- manufacturing technology where a three dimensional object
- is created by successive layers of material. [1]:<a href=
- "http://repthis.info/">http://en.wikipedia.org/wiki/3D_printing</a><br>
-
- <br>
- <a href="http://reprap.org">reprap</a> is a <a href=
- "http://en.wikipedia.org/wiki/Free_software">free</a>
- desktop 3D printer capable of printing plastic
- objects.<br>
- <br>
- <a href="http://repthis.info">repthis.info</a> is the
- account of a friend and I learning to build our own.<br>
- <br></span>
- </div>
-
- <div class="exhibit" id="youtube_backup_">
- <h1 id="youtube_backup_title"><a href=
- "https://github.com/nospampleasemam/youtube_backup">youtube_backup</a></h1><span id="youtube_backup_entry">backs
- up all the <a href="http://youtube.com">youtube</a>
- videos in a users favorites list.<br>
- <br>
- this is my fork of the <a href=
- "https://github.com/hagnas/youtube_backup">original
- youtube_backup</a> which adds asynchronous alerts after
- successful downloads.<br>
- <br>
- it's written in <a href=
- "http://www.python.org/">python</a>.</span>
- </div>
-
- <div class="exhibit" id="i_like_pandora_">
- <h1 id="i_like_pandora_title"><a href=
- "https://github.com/nospampleasemam/i_like_pandora">i_like_pandora</a></h1><span id="i_like_pandora_entry">searches
- <a href="http://youtube.com">youtube</a> for what you
- like on <a href="http://pandora.com">pandora</a>.<br>
- <br>
- then it downloads the first video.<br>
- <br>
- it's working, but i'm still making it better.<br>
- <br>
- <br>
- the code is free (as in freedom), <a href=
- "http://github.com/nospampleasemam/i_like_pandora">here</a>.<br>
- </span>
- </div>
-
- <div class="exhibit" id="peepshow_">
- <h3 id="peepshow_title_1"><a href=
- "foxy-addons/peepshow/peepshow.xpi">foxy-addons/</a></h3>
-
- <h1 id="peepshow_title_2"><a href=
- "foxy-addons/peepshow/peepshow.xpi">peepshow</a></h1><span id="peepshow_entry">a
- <a href=
- "http://www.mozilla.com/en-US/products/download.html">firefox</a>
- addon, to load linked images inline (like on <a href=
- "http://reddit.com/r/pics">reddit</a>).<br>
- <br>
- here's the <a href=
- "http://github.com/nospampleasemam/peepshow/">repo</a>
- for the source code.</span>
- </div>
-
- <div class="exhibit" id="drawcss_">
- <h1 id="drawcss_title"><a href=
- "drawcss">drawcss</a></h1><span id=
- "drawcss_entry">writing markup for website wireframes
- always seemed silly.<br>
- <br>
- this is a tool to draw them (it's not done).<br>
- <br>
- <a href="#show" id="showdivs" name="showdivs">check
- out</a> the invisible divs this page is built on.<br>
- <br>
- then get <a href=
- "http://github.com/nospampleasemam/drawcss">the
- code</a>.</span>
- </div>
-
- <div class="exhibit" id="readoo_">
- <h1 id="readoo_title"><a href=
- "http://github.com/nospampleasemam/readoo">readoo</a></h1><span id="readoo_entry">helps
- you find search keywords to target.<br>
- <br>
- it reads your IIS logs, and finds successful keywords
- worth focusing on.<br>
- <br>
- it's not done yet! here's the <a href=
- "http://github.com/nospampleasemam/readoo">source
- code</a>.</span>
- </div>
- </div>
+ <?php
+ $config = parse_ini_file('/etc/dylanstestserver.ini');
+ mysql_connect($config['domain'], $config['user'], $config['password']) or die(mysql_error());
+ mysql_select_db($config['database']) or die(mysql_error());
+ if (isset($_GET['project'])) {
+ $page_type = 'project';
+ $project = mysql_real_escape_string($_GET['project']);
+ $sql = "SELECT text FROM projects WHERE title='$project'";
+ } else {
+ $sql = "SELECT text FROM projects";
+ }
+ $result = mysql_query($sql) or die (mysql_error());
+ while($project = mysql_fetch_array($result)) {
+ $text = $project['text'];
+ if (isset($page_type)) {
+ $text = str_replace("<div class=\"exhibit\"", "<div class=\"exhibit\" style=\"display:block;\"", $text);
+ }
+ echo $text;
+ }
+ ?>
+ </div>
<ul id="portfolio" style="text-align:right">
<li>
<h3>my projects:</h3>
</li>
- <li><a class="tab" href="#repthis">repthis.info</a></li>
+ <li><a class="tab" href="repthis">repthis.info</a></li>
<li><a class="tab" href=
- "#youtube_backup">youtube_backup</a></li>
+ "youtube_backup">youtube_backup</a></li>
<li><a class="tab" href=
- "#i_like_pandora">i_like_pandora</a></li>
+ "i_like_pandora">i_like_pandora</a></li>
<li><a class="tab" href=
- "#peepshow">foxy-addons/peepshow</a></li>
+ "peepshow">foxy-addons/peepshow</a></li>
- <li><a class="tab" href="#drawcss">drawcss</a></li>
+ <li><a class="tab" href="drawcss">drawcss</a></li>
- <li><a class="tab" href="#readoo">readoo</a></li>
+ <li><a class="tab" href="readoo">readoo</a></li>
<li>
<h3>things i've done for others:</h3>
</li>
<li><a href=
- "notes">here</a></li>
+ "/dylanstestserver/notes">here</a></li>
<li>
<h1 id="contact_me"><a href=
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>dylanstestserver</title>
- <link href="includes/style.css" rel="stylesheet" type="text/css">
- <link rel="icon" href="favicon.ico" type="image/png">
+ <link href="/dylanstestserver/includes/style.css" rel="stylesheet" type="text/css">
+ <link rel="icon" href="/dylanstestserver/favicon.ico" type="image/png">
</head>
<body>
<div id="banner">
<a href=
"http://dylanstestserver.com/">
- <img src="images/dylanstestserver.png" alt="dylanstestserver"
+ <img src="/dylanstestserver/images/dylanstestserver.png" alt="dylanstestserver"
border="0"></a>
</div>
<?php
- mysql_connect('localhost', 'dylan', 'password') or die(mysql_error());
- mysql_select_db('dylanstestserver') or die(mysql_error());
+ $config = parse_ini_file('/etc/dylanstestserver.ini');
+ mysql_connect($config['domain'], $config['user'], $config['password']) or die(mysql_error());
+ mysql_select_db($config['database']) or die(mysql_error());
$sql = "SELECT COUNT(*) FROM notes";
$result = mysql_query($sql);
$result = mysql_fetch_row($result);
$month_posted = $date_posted[1];
$day_posted = $date_posted[2];
$url = $note['url'];
- echo "<h2><span style=\"color:grey;\">$year_posted/$month_posted/$day_posted/</span><a href=\"note/$url\">$title</a></h2>";
+ echo "<h2><span style=\"color:grey;\">$year_posted/$month_posted/$day_posted/</span><a href=\"/dylanstestserver/notes/$url\">$title</a></h2>";
echo $note['text'];
echo "</div>";
}
if(!$page == 2 && $total_number_of_pages == 2)
echo "<a href=\"{$_SERVER['PHP_SELF']}/page/1\">first</a> / ";
$previous_page = $page - 1;
- echo "<a href=\"notes/page/$previous_page\">prev</a>";
+ echo "<a href=\"/dylanstestserver/notes/page/$previous_page\">prev</a>";
}
if($page < $total_number_of_pages) {
$forward_page = $page + 1;
- echo "<a href=\"notes/page/$forward_page\">next</a>";
+ echo "<a href=\"/dylanstestserver/notes/page/$forward_page\">next</a>";
}
if($page != $total_number_of_pages && (!$page == 1 && $total_number_of_pages == 2)){
- echo " / <a href=\"notes/page/$total_number_of_pages\">last</a>";
+ echo " / <a href=\"/dylanstestserver/notes/page/$total_number_of_pages\">last</a>";
}
echo "</h2>";
}
--- /dev/null
+ <div class="exhibit" id="drawcss_">
+ <h1 id="drawcss_title"><a href=
+ "drawcss">drawcss</a></h1><span id=
+ "drawcss_entry">writing markup for website wireframes
+ always seemed silly.<br>
+
+ <br>
+ this is a tool to draw them (it's not done).<br>
+ <br>
+ <a href="#show" id="showdivs" name="showdivs">check
+ out</a> the invisible elements this page is built on.<br>
+ <br>
+ then get <a href=
+ "http://github.com/nospampleasemam/drawcss">the
+ code</a>.</span>
+
+ </div>
--- /dev/null
+ <div class="exhibit" id="i_like_pandora_">
+ <h1 id="i_like_pandora_title"><a href=
+ "https://github.com/nospampleasemam/i_like_pandora">i_like_pandora</a></h1><span id="i_like_pandora_entry">searches
+ <a href="http://youtube.com">youtube</a> for what you
+ like on <a href="http://pandora.com">pandora</a>.<br>
+
+ <br>
+ then it downloads the first video.<br>
+ <br>
+ it's working, but i'm still making it better.<br>
+ <br>
+ <br>
+ the code is free (as in freedom), <a href=
+ "http://github.com/nospampleasemam/i_like_pandora">here</a>.<br>
+
+ </span>
+ </div>
--- /dev/null
+ <div class="exhibit" id="peepshow_">
+ <h3 id="peepshow_title_1"><a href=
+ "foxy-addons/peepshow/peepshow.xpi">foxy-addons/</a></h3>
+
+ <h1 id="peepshow_title_2"><a href=
+ "foxy-addons/peepshow/peepshow.xpi">peepshow</a></h1><span id="peepshow_entry">a
+ <a href=
+ "http://www.mozilla.com/en-US/products/download.html">firefox</a>
+ addon, to load linked images inline (like on <a href=
+ "http://reddit.com/r/pics">reddit</a>).<br>
+
+ <br>
+ here's the <a href=
+ "http://github.com/nospampleasemam/peepshow/">repo</a>
+ for the source code.</span>
+ </div>
--- /dev/null
+ <div class="exhibit" id="readoo_">
+ <h1 id="readoo_title"><a href=
+ "http://github.com/nospampleasemam/readoo">readoo</a></h1><span id="readoo_entry">helps
+ you find search keywords to target.<br>
+ <br>
+ it reads your IIS logs, and finds successful keywords
+ worth focusing on.<br>
+ <br>
+ it's not done yet! here's the <a href=
+ "http://github.com/nospampleasemam/readoo">source
+ code</a>.</span>
+
+ </div>
--- /dev/null
+ <div class="exhibit" id="repthis_">
+ <span id="reprap_entry">3D printing is a form of additive
+ manufacturing technology where a three dimensional object
+ is created by successive layers of material. [1]:<a href=
+ "http://repthis.info/">http://en.wikipedia.org/wiki/3D_printing</a><br>
+
+ <br>
+ <a href="http://reprap.org">reprap</a> is a <a href=
+ "http://en.wikipedia.org/wiki/Free_software">free</a>
+
+ desktop 3D printer capable of printing plastic
+ objects.<br>
+ <br>
+ <a href="http://repthis.info">repthis.info</a> is the
+ account of a friend and I learning to build our own.<br>
+ <br></span>
+ </div>
--- /dev/null
+ <div class="exhibit" id="youtube_backup_">
+
+ <h1 id="youtube_backup_title"><a href=
+ "https://github.com/nospampleasemam/youtube_backup">youtube_backup</a></h1><span id="youtube_backup_entry">backs
+ up all the <a href="http://youtube.com">youtube</a>
+ videos in a users favorites list.<br>
+ <br>
+ this is my fork of the <a href=
+ "https://github.com/hagnas/youtube_backup">original
+ youtube_backup</a> which adds asynchronous alerts after
+ successful downloads.<br>
+ <br>
+
+ it's written in <a href=
+ "http://www.python.org/">python</a>.</span>
+ </div>
import os
import time
-import MySQLdb
+import MySQLdb as db
+import ConfigParser
-db = MySQLdb.connect('localhost','dylan','password', 'dylanstestserver')
-cursor = db.cursor()
+config = ConfigParser.RawConfigParser()
+config.read('/etc/dylanstestserver.ini')
+domain = config.get('database', 'domain')
+user = config.get('database', 'user')
+password = config.get('database', 'password')
+database = config.get('database', 'database')
+cursor = db.connect(domain, user, password, database).cursor()
-notes = os.listdir('notes')
+notes = os.listdir('/home/dylan/docs/notes')
sql = "SELECT title FROM notes"
cursor.execute(sql)
date_posted = "%s-%s-%s" % (str(mtime.tm_year)[2:], mtime.tm_mon, mtime.tm_mday)
sql = "INSERT INTO notes (date_posted, url, title, text)\
VALUES(\"%s\", \"%s\", \"%s\", \"%s\")"\
- % (date_posted, url, title, MySQLdb.escape_string(text))
+ % (date_posted, url, title, db.escape_string(text))
#print sql
cursor.execute(sql)
--- /dev/null
+#!/usr/bin/python
+
+import os
+import time
+import MySQLdb as db
+import ConfigParser
+
+config = ConfigParser.RawConfigParser()
+config.read('/etc/dylanstestserver.ini')
+domain = config.get('database', 'domain')
+user = config.get('database', 'user')
+password = config.get('database', 'password').replace('"', '')
+database = config.get('database', 'database')
+print domain, user, password, database
+cursor = db.connect(domain, user, password, database).cursor()
+
+notes = os.listdir('projects')
+
+sql = "SELECT title FROM projects"
+cursor.execute(sql)
+results = cursor.fetchall()
+existing_titles = []
+for row in results:
+ existing_titles.append(row[0])
+
+for note in notes:
+ title = note[:note.index('.')]
+ f = open(os.path.join('projects', note))
+ if title in existing_titles: continue
+ text = f.read()
+ cursor.execute("INSERT INTO projects (title, text)\
+ VALUES (%s, %s)", (title, text))
--- /dev/null
+# this file will be looked for at /etc/dylanstestserver.ini
+
+[database]
+domain = localhost
+user = dylanstestuser
+password = "dylanstestpassword"
+database = dylanstestserver