Bashblog, static blog generator

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

Bashblog, static blog generator

#1 Post by BarryK »

I have been using pe_pplog, a derivative of PPLOG as my blog engine, for many years. This is a small perl script.

Another derivative of PPLOG is SJPPLOG, and sjpplog_ng. The latter is a continuation of SJPPLOG by 01micko, and is used on puppylinux.com, project page here:
https://github.com/01micko/sjpplog_ng

I recently signed up with a new host, cheap "unlimited" shared account, and I was looking to make a fresh start on what goes into it.

One problem I had with my old blog scripts was how to archive them. I had three old PPLOG/pe_pplog blogs, and I used Httrack to archive them as plain html pages. Done here:
http://bkhome.org/archive/

Using Httrack is inefficient though, as it has to traverse every link it can find, and build a html page for each link.

Then there's the installation, and server overhead when running.

What I really want is a blog that is already static html pages, and hence already archived. A blog that has no installation, nothing to execute on the host, and no server overhead.

The latter means virtually no delay to render the page in your browser, and minimal load on the server. I am very sensitive about server load, as my host hostgator.com cut off my site three times in the past year due to excessive traffic -- there is really no such thing as an "unlimited" account.

Anyway, what I am leading up to is bashblog, a static blog generator. Project page here:
https://github.com/cfenollosa/bashblog

You will see in the github issues, I posted how easy it is to turn into an offline development system.

I hacked the css and a few things, and created a minimalist blog:
http://easyos.info/news/

Even though the server response times of my new host (omnis.com) is not quite as good as hostgator.com, the google speed test gives my site 97/100 for mobile, 95/100 for desktop, which is phenomenal.

Security is another thing. It is just static pages, nothing to break into.

Being static pages, it can't have comments, however it can have a comment plugin. Twitter, Disqus and Google have these. I currently have Disqus commenting enabled, but it will be disabled on the next upload, and I intend to just have a Contact Me form.

I thought perhaps others on this forum might be interested in bashblog, hence this post.

Also, as it has no server overhead, there can be multiple bashblogs on the same account.
In fact, it could be hacked to do other thing, such as a documentation manager. It already has a "tags" page, which could be hacked into the front page.
[url]https://bkhome.org/news/[/url]

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#2 Post by BarryK »

If anyone is interested in hacking bashblog, a search box would be nice :)
[url]https://bkhome.org/news/[/url]

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#3 Post by BarryK »

I am thinking of rewriting bashblog from scratch.

The reason is that bashblog does not scale very well.

The main problem is the "tags" view. If a post is assigned a tag "Linux", then as the blog grows, there could be a lot of posts with that tag.

bashblog, being a static site generator, creates static pages for each tag. Hence, if 1,000 posts have "Linux" tag, then a page is created with 1,000 posts in it!!!!

A verrrry long web page, and that is going to be slow to load, which defeats the whole point of having a static site.

So, do not have "tags" views at all, or have some way of embedding each post.

There is a way to do it, the <iframe> tag:
https://developer.mozilla.org/en/docs/W ... ent/iframe

That works. Many posts can be embedded in a tags-view page, which avoids duplication. Also, there would need to be a cut-off, say, display 8 posts, with a "Next..." button.

The catch is that you would need to know each posts width and height, to specify in the <iframe> tag, so as to avoid scrollbars.
[url]https://bkhome.org/news/[/url]

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#4 Post by wiak »

I use a slightly modified bashblog with bluegriffon WYSIWYG html editor version 1.7.2

bluegriffon 1.7.2 from: http://trac.lliurex.net/xenial/browser/ ... ng?rev=707

but my modded bb.sh would, I expect, also work with Seamonkey since the sed lines I give below were carefully crafted to work even if the whole html page appears as a one-liner... I could no doubt simplify the sed lines, but they are more understandable to me as they are and all proved necessary in my tests of 'annoying' html code line combinations (not just the one where whole html file on one line...). No doubt some html page arrangement could still break things, but all working fine for me so far...

Note that this is just standard bashblog other than having wysiwyg creation/editing capability - I prefer to keep close to that original in case it gets further developed.

The caveat is that I use the 'trick' that the first line Title MUST use tag <h3></h3> around it; reason being that I use that to split up the html code for these annoying cases when the wysiwyg html editor wraps the Title line up with some other lines - I use the h3 tags surrounding the Title as a means of separating that Title out via a combination of some of the sed lines below.

For creation, I've arranged that the Title is automatically using h3 tags. But for editing posts in wysiwyg editor it is important to remember to manually set that line to h3 (or likely will mess up...). I've tried automating putting h3 tags round the Title in edit mode too, but had too many problematic side-effects trying to do that.

Once the following mods are made, I just run bb.sh from a folder locally (I don't bother arranging for files to be written into any other subfolder - just into folder where bb.sh is). Basically, I thereafter just use main bashblog commands:

For creating new post:

Code: Select all

EDITOR=bluegriffon ./bb.sh post -html
For editing existing post:

Code: Select all

EDITOR=bluegriffon ./bb.sh edit <existing_post.html>
Here are the few mods I make to the original current bashblog (version 2.8 ). The following created via diff bb.shORIGINAL bb.shMODDED. In practice I'll likely leave bashblog unmodded and simply use a sed function to dynamically create the modded bashblog in similar way I use makepup to dynamically modify woof-CE scripts in another thread here on Puppy forum). I might publish that makepup-like frontend later, but not sure if I'll get round to doing so since this is enough for my family's current wishes needs, despite some imperfections as it stands:

(Main thing below is to remember it is based on the first line being the Title and that title being surrounded by h3 tags)

Code: Select all

290c290
<         $EDITOR "$1"
---
>         $EDITOR "$(pwd)"/"$1" #wiak added $(pwd)/
300c300
<             $EDITOR "$1"
---
>             $EDITOR "$(pwd)"/"$1" #wiak added $(pwd)/
310c310
<             $EDITOR "$TMPFILE"
---
>             $EDITOR "$(pwd)"/"$TMPFILE" #wiak added $(pwd)/
502a503,517
>     if $(grep -q '<head>' "$1");then #wiak added to only process html header if it exists
>         sed -i -n '/<body[^>]*>/,/<\/body>/p' "$1" #wiak added to select body range
>         sed -i '1s/<body[^>]*>/<body2delete>\n/' "$1" #wiak added to put <body tag on own line
>         sed -i '/<body2delete>/d' "$1" #wiak added to delete <body tag line
>     fi #wiak added
>     sed -i '/./,$!d' "$1" #wiak added to remove any leading blank lines
>     sed -i '1s/<\/h3>/<\/h3>\n/' "$1" #wiak added to put h3 Title line on own line
>     sed -i '2s/^[[:space:]]*<\/h3>//' "$1" #wiak added to remove any leftover /h3 tags on 2nd line
>     sed -i '1s/<h3>//g' "$1" #wiak added to blank out possible leftover <h3> tags on first line
>     sed -i '/./,$!d' "$1" #wiak added to remove any leading blank lines (again)
>     sed -i '1s/[[:space:]]*//; 1s/<[^>]*>//g' "$1" #wiak added to remove all tags from Title line
>     sed -i 's/<p>Tags:/\n<p>Tags:/' "$1" #wiak added to put Tags: line on own line
>     sed -i 's/<\/body/\n<endbody2delete/' "$1" #wiak added to put </body line on own line
>     sed -i '/<endbody2delete>/d' "$1" #wiak added to delete </body line
> 
574c589
<         echo -e "Title on this line\n" >> "$TMPFILE"
---
>         echo -e "<h3>Title on this line</h3>\n" >> "$TMPFILE"
595c610
<         $EDITOR "$TMPFILE"
---
>         $EDITOR "$(pwd)"/"$TMPFILE" #wiak added $(pwd)/
EDIT: Just tried with EDITOR="seamonkey -edit" but find that Seamonkey Composer goes and puts a <br> tag at end of the title inside my <h3> tags, which mucks things up (no such issue with bluegriffon). Anyway, I'll put in a further sed correction to fix that in my bashblog mod in case I publish the simple makepup-like frontend, "makeblog", that I'm currently working on.
EDIT2: Ah... That wasn't the problem. My sed lines already take care of that. Problem was some extra blank lines before the title I needed to sed out before processing the title line. Trying my change now and will modify above code diff thereafter.
EDIT3: OK, just made second copy of the sed line used delete leading blank lines to just after delete <body> tag line above - I think that fixes things to work with both Seamonkey Composer and Bluegriffon now, though still to test thoroughly. Have just re-tested making three blog posts, one with Seamonkey Composer and the next with Bluegriffon (but carefully arranged the source code so all on one line as a test), and third with geany (-i) and worked fine. Back to makeblog frontend now...

wiak

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#5 Post by BarryK »

An update to this thread:

awhile back I forked bashblog, and just about completely rewrote it. The new name is shellCMS.

Project page for shellCMS:

http://bkhome.org/shellcms/

wiak,
Regarding creating and editing with a WYSIWYG HTML editor, that is the basis of shellCMS. I use SeaMonkey Composer.
[url]https://bkhome.org/news/[/url]

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#6 Post by wiak »

BarryK wrote:An update to this thread:

awhile back I forked bashblog, and just about completely rewrote it. The new name is shellCMS.

Project page for shellCMS:

http://bkhome.org/shellcms/

wiak,
Regarding creating and editing with a WYSIWYG HTML editor, that is the basis of shellCMS. I use SeaMonkey Composer.
Hi Barry,

Yes, I'm aware of your shellCMS fork of bashblog, but I want to keep current bashblog untouched aside from inserting the above few lines (10 lines or so) on the fly via my makeblog script, so that I can use the wysiwyg editor with it (and my frontend to actual bashblog should keep working, without change, with later bashblog releases unless I'm unlucky). From what I read about shellCMS, I'm sure it is great and you talk about it scaling better.

However, I'm keen to not add much to the small bashblog script since it is an easy change to simply cut out the html header stuff so that it works with bluegriffon (or any wysiwyg editor). I may be wrong, but I gathered that your shellCMS does away with Markdown support altogether and also limits the number of tags? Anyway, I'm hoping to push changes to bashblog itself in the hope that wysiwyg creation capability will be accepted in it and the author of bashblog states that he doesn't want too many lines of code to be added to it.

Cheers, wiak

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#7 Post by wiak »

Just realised I'll have to modify my sed commands since bashblog is written to be compatible with Linux, MacOS and BSD, without need to install GNU coreutils. In fact I kind of recall that the main developer of bashblog uses a Mac and the sed there doesn't work with some of the options often used with GNU sed. I don't have a Mac to check but from some googling seems standard Mac sed doesn't accept 'sed -i' nor \n in swap replacement patterns and uses -E rather than -r option if you want to turn on extended regular expressions.

May explain why pristine bashblog never uses sed -i ...

Of course I could ignore Mac compatibility... but not happy to do that in the circumstances.

wiak

Post Reply