Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 2nd, 2006, 7:42 PM   #1
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 707
Rep Power: 4 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
Automating blog

I've been working on automating my personal blog lately. I just added a new comment system in php a while back and updating the blog is a daunting task which discourgaes me to make more updates. There is a lot of work put into just making one post. I need to insert a lot of information for file names in about four differnt places in three differnt files. Here is the way I have it set up.

-index.html (The actual blog.)
-monthdateyear.html (Each blog has a corrosponding comment page with that format)
-filewrite.php (The file I wrote to make the comments)

I already wrote a script that asks for the date and the filename I'd like to create, and it automaticly creates the comment page, but I'd also like to insert the dates and filenames directly into index.html and filewrite.php. I was ecen thinking about the script just letting me write the whole body of blog entry and then insert that also. In the end, once I'm done writing the body, it would let me double check it, and then I'll have it automaticly uploaded to my server via ftp.

The problem I have is with automaticly inserting the body and the links into the files. I was thinking about where the body of my blog starts (where all the posts go) putting a comment at the top that would, say <!--body--> and then somehow have Python recognize that, and everytime it sees it, it would place the body with all the links and dates from stored variables right into the page and then save it. What's the general idea of how I would go about doing this?

Also with the PHP file, are you able to put HTML comment tags directly into php, and if not, how would I be able to insert a date into my list of dates. Here is the code in question.
[php]
$pages = array('oct3105.html', 'nov1005.html', 'nov1705.html','nov2505.html','dec1025.html','dec2405.html');
if( in_array($filename, $pages) )
[/php]

What the array does is when the comment goes to be written, it can only write to files in this list so that poeple can enter in code in the URL and put stuff wherever. Everytime I update the blog, I have to go in and manually add in the file name. Is there a way I can have Python recognize that somehow and have it insert the stored date?

Any comments and replies are welcome. My thanks ahead of time.
thechristelegacy is offline   Reply With Quote
Old Jan 3rd, 2006, 1:08 AM   #2
para
Programmer
 
Join Date: Dec 2005
Posts: 65
Rep Power: 3 para is on a distinguished road
Quote:
Originally Posted by thechristelegacy
I've been working on automating my personal blog lately. I just added a new comment system in php a while back and updating the blog is a daunting task which discourgaes me to make more updates. There is a lot of work put into just making one post. I need to insert a lot of information for file names in about four differnt places in three differnt files. Here is the way I have it set up.
I don't know much about PHP, or web design for that matter, but I find PHPBb to be an excellent system. I can't really answer your question though since I've never touched Python, but I recommend giving PHPBb a shot as being your backend, and writing a small frontend for grabbing information generated by it and displaying it on your page. With this you have all the neat little features of a full forum, but you can display it in a blog-like format. I recently used this approach for a devlog I started, works great.

http://www.phpbb.com/

-edit-
OH, you can also use the Smarty template engine ( http://smarty.php.net/ ) to help generate your output. Very nice stuff
para is offline   Reply With Quote
Old Jan 3rd, 2006, 4:17 AM   #3
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4 Arevos is on a distinguished road
You can use C-style comments in PHP:
[php]$pages = array('oct3105.html', 'nov1005.html' /*@date */);[/php]And in Python you can easily replace a substring with something else, by using 'replace':
file = open("filewrite.php", "r")
file_contents = file.read()
file.close()
new_contents = file_contents.replace("/* @date */", new_date + "/* @date */");
file = open("filewrite.php", "w")
file.write(new_contents)
file.close()
However this might not be the best way to go about it. Usually, blogs store the comment and post data in a database or XML file, and then either generate the HTML on the fly, or to use caching and generate it only when the stored data is changed. Storing data directly to HTML is a bit of a headache, especially with user-created content.

There's also a lot of open source blogging software out there already. Just type "php blog" into Google and you'll see what I mean. Using off-the-shelf blogging systems might make it easier for you.
Arevos is offline   Reply With Quote
Old Jan 3rd, 2006, 6:29 AM   #4
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 707
Rep Power: 4 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
Thanks for the replies. Eventually I do want to move it to a database or XML file, but I need to do a lot more learning. I'm going to try Arevos's method when I return home from school today, it looks quite promissing for what I need.

Thanks again.
thechristelegacy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:16 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC