From a74a20d64f0c3c757c9a97f9f9a858adca266221 Mon Sep 17 00:00:00 2001 From: Dylan Lloyd Date: Wed, 16 Feb 2011 01:29:39 -0500 Subject: [PATCH] notes/ now working! --- .gitignore | 3 ++ .htaccess | 5 ++++ includes/style.css | 6 ++++ index.php | 8 +++--- notes/index.php | 22 +++++---------- notes/notes.php | 69 ++++++++++++++++++++++++++++++++++++++++++++++ publish.py | 33 ++++++++++++++++++++++ 7 files changed, 127 insertions(+), 19 deletions(-) create mode 100644 .gitignore create mode 100644 notes/notes.php create mode 100755 publish.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c3fa09 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +notes/* +!notes/index.php +!notes/notes.php diff --git a/.htaccess b/.htaccess index fe7ef14..f58eeb4 100644 --- a/.htaccess +++ b/.htaccess @@ -1 +1,6 @@ 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 diff --git a/includes/style.css b/includes/style.css index 5e993a4..265fcca 100644 --- a/includes/style.css +++ b/includes/style.css @@ -69,6 +69,7 @@ li { #contact_me { margin-top:100px; + font-family:sans-serif; } /* reprap */ @@ -140,6 +141,7 @@ li { #notes h2 { margin-bottom:10px; + font-family:sans-serif; } .note { @@ -149,3 +151,7 @@ li { .note p { margin-bottom:5px; } + +pre { + margin-top:10px; +} diff --git a/index.php b/index.php index 965d933..c0971b1 100644 --- a/index.php +++ b/index.php @@ -157,18 +157,18 @@ "http://tempositions.com">tempositions.com
  • -

    my github repo:

    +

    my repositories:

  • github@github.com:nospampleasemam
  • + "git">git://dylanstestserver.com
  • -

    my repo:

    +

    some notes:

  • git://dylanstestserver.com
  • + "notes">here
  • dylanstestserver - - + + @@ -17,24 +17,16 @@
    -
    -

    Amazon EC2 PTR/reverse DNS record/2/15/10

    -

    Here is the form to request a custom PTR record for an Amazon EC2 Elastic IP. It's listed, of course, under Request to Remove Email Sending Limitations, and took me an unfortunate amount of time to locate.

    -

    This is good when setting up a mail server in Amazon's cloud, since email providers (like gmail) flag mail whose reverse DNS does not match the MX record. Without this request, the reverse DNS lookup will return the default PTR record that will look something like ec2-50-16-219-8.compute-1.amazonaws.com

    -
    -
    -

    init/2/15/10

    -

    Every other day I manage to get something working with help from a blog I find with google that just-so-happens to include a detail the manual spares. These notes are in the hope of helping in the same way. I don't plan on writing often, and there will be no order to the notes; in this way these notes are meant more for spiders than humans.

    -
    -

    dylan

    @psu.edu + +

    dylan

    @psu.edu
    diff --git a/notes/notes.php b/notes/notes.php new file mode 100644 index 0000000..26148a4 --- /dev/null +++ b/notes/notes.php @@ -0,0 +1,69 @@ +"; + $title = $note['title']; + $date_posted = explode("-", $note['date_posted']); + $year_posted = $date_posted[0]; + $month_posted = $date_posted[1]; + $day_posted = $date_posted[2]; + echo "

    $year_posted/$month_posted/$day_posted/$title

    "; + echo $note['text']; + echo ""; + } + } else { + if (isset($_GET['page']) && is_numeric($_GET['page'])) { + $page = (int) $_GET['page']; + } else { + $page = 1; + } + if ($page < 1) { + $page = 1; + } else if ($page > $total_number_of_pages) { + $page = $total_number_of_pages; + } + $page_offset = ($page - 1) * $notes_per_page; + $notes = mysql_query("SELECT title, date_posted, text, url + FROM notes ORDER BY date_posted DESC + LIMIT $page_offset, $notes_per_page"); + while($note = mysql_fetch_array($notes)) { + echo "
    "; + $title = $note['title']; + $date_posted = explode("-", $note['date_posted']); + $year_posted = $date_posted[0]; + $month_posted = $date_posted[1]; + $day_posted = $date_posted[2]; + $url = $note['url']; + echo "

    $year_posted/$month_posted/$day_posted/$title

    "; + echo $note['text']; + echo "
    "; + } + echo "

    "; + if($page != 1){ + if(!$page == 2 && $total_number_of_pages == 2) + echo "first / "; + $previous_page = $page - 1; + echo "prev"; + } + if($page < $total_number_of_pages) { + $forward_page = $page + 1; + echo "next"; + } + if($page != $total_number_of_pages && (!$page == 1 && $total_number_of_pages == 2)){ + echo " / last"; + } + echo "

    "; + } +?> diff --git a/publish.py b/publish.py new file mode 100755 index 0000000..b0847ff --- /dev/null +++ b/publish.py @@ -0,0 +1,33 @@ +#!/usr/bin/python + +import os +import time +import MySQLdb + +db = MySQLdb.connect('localhost','dylan','password', 'dylanstestserver') +cursor = db.cursor() + +notes = os.listdir('notes') + +sql = "SELECT title FROM notes" +cursor.execute(sql) +results = cursor.fetchall() +existing_titles = [] +for row in results: + existing_titles.append(row[0]) + +for note in notes: + if note == 'index.php' or note == 'notes.php': continue + url = note[:note.index('.')] + f = open(os.path.join('notes', note)) + title = str(f.readline()[:-1]) + text = ''.join(f.readlines()) #converts list to single string + if title in existing_titles: continue + mtime = time.localtime(os.path.getmtime(os.path.join('notes', note))) + 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)) + + #print sql + cursor.execute(sql) -- 2.30.2