Fork me on GitHub

pe_pplog demo page

Main menu

RSS feed

No comments
It is possible to parse a RSS feed with JQuery and thus with some friendly help from Paul and the internet I wrote a small script to display an RSS feed in the menu (in this case the latest entries of my travel blog):



This is the script:
<script>	var rssurl=\'pup_pplog.pl/?do=RSS\';

$.get(rssurl, function(data) {
var $xml = $(data);
var $item = $xml.find("item").slice(0,5);
$item.each(function() {
var $this = $(this),
item = {
title: $this.find("title").text(),
link: $this.find("link").text(),
description: $this.find("description").text()
}

$("#feed-container").append($(\'<a></a>\').attr(\'href\',item.link).attr(\'target\',\'_blank\').html(item.title), $(\'<p></p>\').html(item.description));
});
});
</script>
<!-- Edit the following according to need -->
<h1>Travel Blog Entries</h1><div class="slide"><a id="flip" href="/travel" target="_blank">view travel blog »</a><div class="hide" id="feed-container">


Add to "our $config_customMenuHTMLbottom". Only works with RSS feeds from the same domain.





An event calendar

No comments
This was supposed to be a post akin to the Social Share Buttons one, with a lot of different options, but I only found one JQuery calendar that was lightweight and easy to set up, FullCalendar.

My set up of it looked like this:
cal-monthcal-weekcal-day

I downloaded the files from the website and put them in the /js folder on my server home.
The I put this:
<link rel="stylesheet" type="text/css" href="/js/fullcalendar.css" />
<script type="text/javascript" src="/js/fullcalendar.js"></script>


in "our $config_customHTMLhead" and "our $config_customHTMLadmin"

Then I made a new entry with the following content:
cal-code

and checked "is HTML".

As you can see events are added in the initialization script, see the webpage for more options, such as google calendar integration.

As an extra I wrote a short script replacing the traditional archive with a calendar with click-able links:
cal-archive

replace "doArchive();" in pe_pplog.pl (around line 750) and/or pe_admin.pl (around line 910)
with the following:

print '<h1>'.$locale{$lang}->{archive}.'</h1><script>$(document).ready(function() {

$(\'#calendar\').fullCalendar({
events: [';
my @entries = getFiles($config_postsDatabaseFolder);
print $locale{$lang}->{noentries} if scalar(@entries) == 0;
# Split the data in the post so i have them in this format "13 Dic 2008, 24:11|0001|Entry title" date|fileName|entryTitle
my @dates = map { my @stuff = split(/¬/, $_); @stuff[2].'|'.@stuff[4].'|'.@stuff[0]; } @entries; #25.05.13 jamesbond
my $year;
my $month;
my %months = (Jan=>"01", Feb=>"02", Mar=>"03", Apr=>"04", May=>"05",
Jun=>"06", Jul=>"07", Aug=>"08", Sep=>"09", Oct=>"10", Nov=>"11", Dic=>"12"); #hash to change shots into numbers for events
my $day;
foreach(@dates)
{
my @date = split(/\|/, $_);
my @y = split(/\s/, $date[0]);
$y[2] =~ s/,//; #get rid of the comma!
$day = $y[0];
unless ($day =~ /\d\d/){$day = '0'.$day;} #day needs to be double digit 01 instead of 1
$month = $y[1];
$year = $y[2];
print "{title: '$date[2]', url: '?viewDetailed=$date[1]', start: '$year-$months{$month}-$day'},"; #writing the entries as calendar events
}
print ']
})
});</script><div id="calendar"></div>';


and add the javascript and css file as above


Language support

No comments
As you can see in the main menu it is possible to choose a language (cookies need to be enabled).
This is not going to be a feature, it is a way for me to test (and demonstrate) localisation of the blog. There will be a proper German and English version (with documentation being in either language) and Spanish localisation available, as well as an incomplete Greek one (taken from the translation of the original PPLOG done by koulaxizis.
There will also be the possibility to add a custom translation if one wishes so.

I'm still busy with spellchecking and correction of the Spanish translation. Please inform me of any mistakes you might find...

The localisation does not depend on any additional modules or programs, I quickly abandoned the idea of gettext and the like and relied instead on a simple hash in the pe_Config.pl file, such as:

our%locale;

$locale {"EN"} = {
menu => "Main Menu",
...
};
$locale {"DE"} = {
menu => "Hauptmenu",
...
}


setting the language with our $lang=...
This means I replaced all text in the blog with:
$locale{$lang}->{key}

I wonder what this says about me...

Anyway, here is what I threw together for the "set language" button and the "set style" button.
After the "do RSS section":

	my $style = cookie('style');

my $language = cookie ('lang');

$config_currentStyleSheet = $style if defined $style;
$lang = $language if defined $language;

if (r('style') ne ''){
my $style = r('style').".css";
my $cookie = cookie (-name => 'style', value => $style);
$config_currentStyleSheet = $style;
print header (-charset => qw(utf-8), -cookie => $cookie);
}
elsif (r('lang') ne ''){
$lang = r('lang');
my $cookie = cookie (-name => 'lang', value => $lang);
print header (-charset => qw(utf-8), -cookie => $cookie);
}
else {print header(-charset => qw(utf-8));}


Menu entries:
print '<ul class="menu"><li><a class="menu" href="#">Set Style »</a><ul class="drop">

<li><a href="?style=style">Default</a></li>
<li><a href="?style=darkgrey">Dark Grey</a></li>
</ul></li></ul>';

print '<ul class="menu"><li><a class="menu" href="#">Set Language »</a><ul class="drop">';
foreach (keys%locale){
print '<li><a href="?lang='.$_.'">'.$_.'</a></li>';
}
print '</ul></li></ul>';


fun!



Version 2b (bugfix version) released

No comments
This is a bugfix version of pe_pplog v2. Please see the changelog for details. Again there are two pets available, one for a hiawatha and one for a lampp server.

I'm quite happy with this version so if there are any new release they will probably be bugfixes.
As for now I'm going to focus my energies on translating the blog, plugins and different themes.

It can be downloaded from the link to your right. ->


Security tips

No comments
Use the captcha or security question for comments or automatic spambots will find you and flood your blog (I learned that the hard way)

Use https for the admin page, especially when using an open wifi connection (the next version of the blog will have an automatic redirect when $config_useHTTPSlogin = 1;

Log out when done (as this will delete your cookie and the server side session file)
Posted on - Categories: security


Pages: ... [2] [3] [4] [5] [6] [7] ...