![]() |
FAQ/Help |
Calendar |
Search |
#1
|
|||
|
|||
I just posted a question about upgrading, and I have another....
I would like to have a small 'ssi' or something similar that would announce the date/title/blurb of the last journal entry on a front web page. (something like the index page, but JUST the last entry, so when a person enters the main page of the web site, they can see when the last journal entry is). I thought of adding a small subroutine that would create/overwrite a new file with date/title/blurb and then include that on the front page as a SSI "include file...". Though I can write the subroutine, I'm not sure where to put it in the script, the variables to use etc. Can anyone help? Has this been done for OJ 1.17 for 2.x? |
#2
|
|||
|
|||
Ok, I've worked this out.
Some Caveats First: 1. It is probably not the most elegant solution, I'm not a perl expert 2. I make no claims to whether this will screw anything up, I've tested it several times and it seems to work 3. this is for version 1.x. If I upgrade to 2.x I'll figure how to do it for that, but I don't want to upgrade till I know I can use my previous entries. Ok, if you want a small announcement of you latest entry on the 'home' page of your site (assuming the journal is not), these are the steps: (you will need to be able to use SSI on your site) 1.Find in openjournal.cgi the subroutine "sub new_file" after the lines: close(NEWFILE); chmod 0755, "$basedir/$mesgdir/$nfn\.$ext"; ADD: open (UPDATE, ">../jim/lastupdate.txt"); print UPDATE "$etitle||$long_date||$ptime||$bodyone"; print UPDATE "\n"; close (UPDATE); chmod 0777, "PATHTOFILE/lastupdate.txt"; (right before the "}" This creates a text file "lastupdate.txt" with the long date of the last update, the time, title and blurb. Substitute the PATHTOFILE to the path to the directory you want to add the file in, I suggest this not be the cgi bin, but perhaps where your openjournal files are. 2. Then copy and paste the following into a new file and name it ojlast.cgi (or whatever you want), make the changes as shown in comments, upload the file and change permissions to 755: #!/usr/bin/perl ########################## #make sure the path above is correct for yours #another common is !/usr/local/bin/perl ########################## # Path to data files. (No ending slash.) $data_location = "PATHTOWHERE lastupdate.txt is"; # File name of file containing data: $file = "lastupdate.txt"; ########################## #reads data file lastupdate.txt and prints it off #a bit overkill since I wrote it in case some day #i want to report the last several updates ########################## print "Content-type: text/html\n\n"; open (QUOTEFILE, "<$data_location/$file") || die print "Could not open links file"; @line=<QUOTEFILE>; close (QUOTEFILE); foreach $link (@line) { @newlink = split (/\|\|/, $link); print "The latest journal entry:"; print "(A HREF=\"URLOFOPENJOURNAL\""; print ")$newlink[0](/a), $newlink[3]"; print "posted on $newlink[1] " ################################ #substitute the "( and )" with "< and >" here I forgot how to make this # board not do html ![]() ################################## } exit; ########################## #The above will print off something like: #The latest journal entry: #TITLE, Blurb #posted on DATE # you can add another print statement with #newlink[2] to add the time # my web site formatting is governed by a style sheet, #so this has very little styling. If you know HTML, you #can easily change this to look how you want it ########################## 3. Then on the page where you want the last update to show up (usually must have a .shtml extension) (!--#exec cgi="Path to your ojlast.cgi script you just created"--) Again, change the ( and ) to < and > |
#3
|
|||
|
|||
you can see an example of what I did at a web page I started for a brother
![]() if you have any questions, or suggestions or better way to do this, post here or email me at wclathe @aol.com (minus the space) |
#4
|
|||
|
|||
OOPs,
In EVERY instance I have lastupdate.txt, substitute another name like 'mostrecent.txt' or 'latest.txt' or something. There would be no problem if you have the file reside anywhere BUT the openjournal file, but there is a file there already at that name and you DO NOT want to replace it which this would. Just name it something else. Sorry, trey |
Reply |
|
![]() |
||||
Thread | Forum | |||
Weblog entry: Privacy while blogging | Other Mental Health Discussion | |||
Weblog entry: Lying | Other Mental Health Discussion | |||
How to edit or remove entry? | Community Feedback & Technical Support | |||
OpenJournal formatting question: titles/article & entry | Community Feedback & Technical Support |