You are not logged in.

#1 2010-08-21 12:19:10

neofish
Member
Registered: 2010-02-13
Posts: 25

mBlog - minimalist blog software written in php

I made mBlog for an assignment, but it turned out that it's just the kind of thing that Arch linux users would like.

It reads all of the files from a specified directory, and displays them in a html page.

I only just learnt php this afternoon, so it's really simple and small.  Any suggestions on how to improve the code are most welcome smile

http://github.com/neofish/mBlog/raw/master/index.php

Last edited by neofish (2010-08-21 12:26:30)

Offline

#2 2010-08-24 22:09:32

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: mBlog - minimalist blog software written in php

wow you weren't kidding with the minimalist. It's really short, but I'm sure you could improve on that a bit further. For example make the computer do the boring work like putting the title of a blog post into the needed html tags. Or stuff like that. Just automate it a bit further, because else you can just have one html file to write everything into (which is it's own nice thing on its own smile )

But it's a cool minimalist idea!

cheers
Barde

Offline

#3 2010-08-25 07:53:27

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: mBlog - minimalist blog software written in php

fwiw, for the uzbl website we made something similar, using the phatso php micro-framework from Judd V.
it's similar, but supports markdown formatting and simple url routing.
http://github.com/Dieterbe/uzbl-website


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#4 2010-08-25 13:19:30

gtklocker
Member
Registered: 2009-09-01
Posts: 462

Re: mBlog - minimalist blog software written in php

I can't understand how it works yikes

Offline

#5 2010-08-26 05:08:54

fiendskull9
Member
Registered: 2010-08-26
Posts: 5

Re: mBlog - minimalist blog software written in php

i expanded upon this into my own little mini blog script, this was a great idea

http://www.notwavingbutdrowning.info/blog/

Offline

#6 2010-08-26 06:27:41

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: mBlog - minimalist blog software written in php

neofish wrote:

Any suggestions on how to improve the code are most welcome smile

Try to get it to validate, at least for most expected input (wrapping the content in <pre> tags might be enough to encapsulate it).


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#7 2010-08-26 07:12:20

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: mBlog - minimalist blog software written in php

I believe the C-style comments at the top will interfere with your output, since they are not wrapped in <?php ... ?>. (Note that I have not written PHP in ages.)

fiendskull9 wrote:

i expanded upon this into my own little mini blog script, this was a great idea

http://www.notwavingbutdrowning.info/blog/

It's good to see I'm not the only person who uses 'cock' as a metasyntactic variable. tongue

Offline

#8 2010-08-26 10:03:38

neofish
Member
Registered: 2010-02-13
Posts: 25

Re: mBlog - minimalist blog software written in php

As I said, I'm VERY new to php, so the original script is the best I could do.

Fixed up the comments and added a readme.  I'm currently working on validating it <.<
>.>.

Please feel free to give me patches, I'm more than happy to use anyone's suggestions.  (and thanks for everything mentioned so far)

Offline

#9 2010-08-26 12:43:31

upsidaisium
Member
From: Vietnam
Registered: 2006-09-16
Posts: 263
Website

Re: mBlog - minimalist blog software written in php

It would be very easy to add Markdown support, which - I think - most people would like. You can download it at the PHP Markdown site and then add the line..

require_once 'markdown.php';

..to the top of your file. (Within the <?php .. ?> tags, of course).

And then you're able to simplify your printFile() function a bit:

function printFile($file) {
  echo Markdown(file_get_contents($file));
  echo '<hr />';
}

Edit: and here's the PHP doc page for file_get_contents(), in case you haven't come across it before.. smile

Last edited by upsidaisium (2010-08-26 12:46:06)


I've seen young people waste their time reading books about sensitive vampires. It's kinda sad. But you say it's not the end of the world... Well, maybe it is!

Offline

#10 2012-03-08 08:48:33

neofish
Member
Registered: 2010-02-13
Posts: 25

Re: mBlog - minimalist blog software written in php

Just updated this with most of the suggestions made, slow development much tongue

I have added markdown, file_get_contents() (fgets was a stupid idea), css, and have wrapped the posts up in <article> tags.

http://github.com/neofish/mBlog

Offline

Board footer

Powered by FluxBB