Skip to content

Commit 2d7e78e

Browse files
author
Paul Bersch
committed
Initial Commit
0 parents  commit 2d7e78e

33 files changed

+5477
-0
lines changed

.post.py.swp

16 KB
Binary file not shown.

ajaxedit.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
require_once('postfunctions.php');
4+
$postID = $_POST["id"];
5+
$width = $_POST["width"];
6+
$width = $width - 10;
7+
$height = $_POST["height"];
8+
9+
$postTitle = getPostSubject($postID);
10+
$rawText = getRawPost($postID);
11+
12+
$filledTextarea = '<input type="text" name="input_title" id="input_title" value="'.$postTitle.'"> <br />'.'<textarea id="input_body" style = "width:'.$width.'px; height:'.$height.'px;">'.$rawText.'</textarea>'.
13+
' <br /> <form action="edit.php" method="post" name="postForm" id="postForm"> <input type="hidden" name="post_title" id="post_title">'.
14+
' <input type="hidden" name="post_body" id="post_body">'.
15+
' <input type="hidden" name="post_date" id="post_date" value="'.$postID.'">'.
16+
' <input type="button" value="Submit Post" onclick="fill_form_and_escape('.$postID.')">'.
17+
' <input type="button" value = "Cancel" onclick = "cancelEditing()"> </form>';
18+
19+
echo $filledTextarea;
20+
21+
?>
22+

ajaxget.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
require_once('postfunctions.php');
4+
$postID = $_POST["id"];
5+
6+
$postTitle = getPostSubject($postID);
7+
$rawText = getMarkupPost($postID);
8+
9+
$filledPost =
10+
'<h2 id = "' . $postID . '_title" class="thesubject">' .
11+
$postTitle . '</h2>' .
12+
$rawText;
13+
14+
echo $filledPost;
15+
16+
?>
17+

ajaxnewpost.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<input type="text" name="input_title" id="input_title">
2+
<br />
3+
<textarea name="input_body" rows="10" cols="80" id="input_body"></textarea>
4+
<br />
5+
<form action="submit.php" method="post" name="postForm">
6+
<input type="hidden" name="input_title" id="post_title">
7+
<input type="hidden" name="input_body" id="post_body">
8+
<input type="button" value="Submit Post" onclick="
9+
function() {
10+
var postID = <?php echo date(YmdHis); ?>;
11+
$('.hidden').attr('id', postid);
12+
fill_form_and_escape(postID);
13+
setClickable();
14+
};">
15+
<input type="button" value="Cancel" onclick="$('.hidden').remove(); cancelEditing();">
16+
</form>

antiquated/index (copy).php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/*
3+
* index.php
4+
*
5+
* Copyright 2007 Paul <Paul@localhost>
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20+
* MA 02110-1301, USA.
21+
*/
22+
?>
23+
24+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
25+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
26+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
27+
28+
<head>
29+
<title>untitled</title>
30+
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
31+
<meta name="generator" content="Geany 0.12svn" />
32+
</head>
33+
34+
<body>
35+
36+
37+
38+
<?php
39+
/*magical script to parse directory of text files into magical posts!*/
40+
if ($handle = opendir('posts/')) {
41+
while (false !== ($file = readdir($handle))) {
42+
if ($file != "." && $file != "..") {
43+
$fh = fopen('posts/'.$file, 'r');
44+
$post = fread($fh, filesize('posts/'.$file));
45+
$posts .= $post;
46+
}
47+
}
48+
closedir($handle);
49+
}
50+
?>
51+
<p>The early prototype blog!!! You are of the chosen few!!!</p>
52+
<?=$posts?>
53+
54+
</body>
55+
</html>

antiquated/index.php.bak.php

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
/*
3+
* index.php
4+
*
5+
* Copyright 2007 Paul <Paul@localhost>
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20+
* MA 02110-1301, USA.
21+
*/
22+
?>
23+
24+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
25+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
26+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
27+
28+
<head>
29+
<title>untitled</title>
30+
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
31+
<meta name="generator" content="Geany 0.12svn" />
32+
<link rel="stylesheet" type="text/css" href="theme/style.css">
33+
</head>
34+
35+
<body>
36+
37+
<h1>The early prototype blog!!! You are of the chosen few!!!</h1>
38+
39+
<a href = "http://www.wellstyled.com/tools/colorscheme2/index-en.html?triad;21;0;220;-1;-1;1;-0.7;0.25;1;0.5;1;-1;-1;1;-0.7;0.25;1;0.5;1;-1;-1;1;-0.7;0.25;1;0.5;1;-1;-1;1;-0.7;0.25;1;0.5;1;0">Colors</a>
40+
41+
<?php
42+
/*magical script to parse directory of text files into magical posts!*/
43+
require_once('./textile/classTextile.php');
44+
45+
if ($handle = opendir('posts/')) {
46+
while (false !== ($file = readdir($handle))) {
47+
//run through each file in the directory
48+
if ($file != "." && $file != "..") {
49+
//create an array of filenames
50+
$filearray[] = trim($file);
51+
}
52+
}
53+
natcasesort($filearray); //sort filenames
54+
55+
foreach ($filearray as $file){
56+
//add markup to posts and put them together with the newest post on top
57+
$fh = fopen('posts/'.$file, 'r');
58+
$title = fgets($fh);
59+
$title = substr($title, 0, -1);
60+
$post = fread($fh, filesize('posts/'.$file));
61+
$post = substr($post, 1);
62+
//cause the body of the post to be textile-ified
63+
$textile = new Textile();
64+
$post = $textile->TextileThis($post);
65+
//make the date (more) human-readable
66+
$prettydate = substr($file,4,2).'/'.substr($file,6,2).'/'.substr($file,0,4).' at '.
67+
substr($file,-6,2).':'.substr($file,-4,2).':'.substr($file,-2);
68+
$posts = "\n".'<h3 class="time">'.$prettydate.'</h3>'."\n".'<div id="'.$file.'" class="thebody">'.
69+
"\n".$post."\n".'</div>'."\n".'</div>'."\n".$posts;
70+
$posts = '<div class="thepost">'."\n".'<h2 id = "'.$file.'_title" class="thesubject">'.$title.'</h2>'.$posts;
71+
}
72+
$posts = '<div id="posts">'."\n".$posts;
73+
$posts.="\n".'</div>';
74+
closedir($handle);
75+
}
76+
echo $posts;
77+
?>
78+
79+
<p style = "font-size: 22pt;">footer text here</p>
80+
81+
</body>
82+
</html>

antiquated/index.php.bak2

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/*
3+
* index.php
4+
*
5+
* Copyright 2007 Paul <Paul@localhost>
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20+
* MA 02110-1301, USA.
21+
*/
22+
?>
23+
24+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
25+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
26+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
27+
28+
<head>
29+
<title>untitled</title>
30+
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
31+
<meta name="generator" content="Geany 0.12svn" />
32+
<link rel="stylesheet" type="text/css" href="theme/style.css">
33+
</head>
34+
35+
<body>
36+
37+
<h1>The early prototype blog!!! You are of the chosen few!!!</h1>
38+
39+
<a href = "http://www.wellstyled.com/tools/colorscheme2/index-en.html?triad;21;0;220;-1;-1;1;-0.7;0.25;1;0.5;1;-1;-1;1;-0.7;0.25;1;0.5;1;-1;-1;1;-0.7;0.25;1;0.5;1;-1;-1;1;-0.7;0.25;1;0.5;1;0">Colors</a>
40+
41+
<?php
42+
43+
require_once('./postfunctions.php');
44+
45+
markupPosts();
46+
47+
?>
48+
49+
<p style = "font-size: 22pt;">footer text here</p>
50+
51+
</body>
52+
</html>

edit.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
require_once('postfunctions.php');
4+
$title = urldecode($_POST["post_title"]);
5+
$body = urldecode($_POST["post_body"]);
6+
$postedtime = $_POST["post_date"];
7+
8+
$out = fopen('posts/'.$postedtime, "w");
9+
if (!$out)
10+
{
11+
echo false;
12+
exit;
13+
}
14+
fwrite($out, $title."\n");
15+
fwrite($out, "\n".$body."\n");
16+
fclose($out);
17+
createIndexFile();
18+
//echo "header('Location: index.html');";
19+
//echo '<script type="text/javascript"> cancelEditing(); </script>';
20+
echo 'Post Saved';
21+
?>

index.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
$indexpage = null;
4+
5+
require_once('./postfunctions.php');
6+
7+
createIndexFile();
8+
9+
header('Location: index.html');
10+
?>

js/functions.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
var ajax = false;
2+
3+
if (window.XMLHttpRequest) {
4+
ajax = new XMLHttpRequest();
5+
}
6+
else if (window.ActiveXObject) {
7+
try {
8+
ajax = new ActiveXObject("Msxml2.XMLHTTP");
9+
}
10+
catch (e1) {
11+
try {
12+
ajax = new ActiveXObject("Microsoft.XMLHTTP");
13+
}
14+
catch(e2) {}
15+
}
16+
}
17+
18+
if (!ajax) {
19+
alert('Ajax object could not be created. Please use a less sucky browser.');
20+
}
21+
22+
23+
function fill_form_and_escape(postID) {
24+
25+
var con = document.getElementById('input_body').value;
26+
var tit = document.getElementById('input_title').value;
27+
28+
var titleID = postID + "_title";
29+
var contentID = postID + "_body";
30+
31+
con = escape(con); //fixes escaped
32+
tit = escape(tit); //apostrophe problem
33+
var data = "post_title=" + tit + "&post_body=" + con + "&post_date=" + postID;
34+
35+
ajax.open('POST', 'edit', true);
36+
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
37+
ajax.send(data);
38+
$('.hidden').ajaxSuccess(updatePost(postID));
39+
}
40+
41+
function setClickable() {
42+
$('.post').dblclick(function() {
43+
cancelEditing();
44+
var self = this;
45+
var currentHTML = $(this).html();
46+
var postID = $(this).attr("id");
47+
var postWidth = $(this).width();
48+
var postHeight = $(this).height();
49+
var newElement = document.createElement('div');
50+
newElement.setAttribute('class', 'editing');
51+
newElement.setAttribute('id', "editTextarea");
52+
newElement.setAttribute('style', 'display: none');
53+
$(this).after(newElement);
54+
$(this).addClass("hidden");
55+
56+
$('#editTextarea').load("ajaxedit", {"id": postID, "width": postWidth, "height": postHeight }, function() {
57+
$('#editTextarea').show();
58+
$(self).slideUp("fast");
59+
});
60+
})
61+
};
62+
63+
function newPostSetClickable() {
64+
$('.createnew').click(function() {
65+
cancelEditing();
66+
var newElement = document.createElement('div');
67+
newElement.setAttribute('class', 'editing');
68+
newElement.setAttribute('id', "editTextarea");
69+
newElement.setAttribute('style', 'display: none');
70+
var newPost = document.createElement('div');
71+
newPost.setAttribute('class', 'post hidden');
72+
newPost.setAttribute('style', 'display: none');
73+
$(this).after(newPost);
74+
$(this).after(newElement);
75+
76+
$('#editTextarea').load("ajaxnewpost", {"width": 1, "height": 2 }, function() {
77+
$('#editTextarea').show("fast");
78+
});
79+
80+
})
81+
}
82+
83+
function updatePost(postID) {
84+
$('#editTextarea').remove();
85+
//var newElement = document.createElement('div');
86+
//newElement.setAttribute('class', 'post');
87+
//newElement.setAttribute('id', postID);
88+
//$('.hidden').after(newElement);
89+
//$('.hidden').remove();
90+
91+
$('.hidden').load("ajaxget", {"id": postID});
92+
$('.hidden').show("fast");
93+
$('.hidden').removeClass("hidden");
94+
95+
// var newElement = document.createElement('div');
96+
// newElement.setAttribute('class', 'post newelement');
97+
// newElement.setAttribute('style', 'display: none');
98+
// $('.hidden').after(newelement);
99+
// $('.hidden').replaceWith(newElement);
100+
// $('.hidden').load("ajaxget", {"id": postID});
101+
// $('.hidden').show("fast");
102+
// $('.hidden').removeClass("hidden");
103+
104+
}
105+
106+
function cancelEditing() {
107+
$('#editTextarea').hide("fast", function() { $(this).remove(); });
108+
//$('#editTextarea').remove();
109+
$('.hidden').show("fast");
110+
$('.hidden').removeClass("hidden");
111+
}
112+

0 commit comments

Comments
 (0)