General Discussion > Web Programming and Design

Sorunome.de re-write

(1/7) > >>

Sorunome:
Yep, I am re-writing sorunome.de - from scratch!
I've been working on it since quite some time now.
EDIT: public! www.sorunome.de

At first look it looks more or less the same like the current one, but the software behind it is so much more awesome!
First of all, every single request for that domain gets re-directed to the same php script, the url path as a parameter.
From there i check for if you want, let's say, an image.
Copying the image and then displaying it, pretty simple. But i also allowed it to server-side rescale it before sending - only by modifying the path!
Let's take a look: http://sorunome.reubenquest.net/*/75/media/knex/ballmachines/crazy/crazy_top.jpg
the /*/75/ is the important path, first you say width, then height. If it is * that means it'll get fixed to match the proportions. If you completley omit that you get the original.

Ok, images aside, the awesomeness just began!
When calling a normal page it looks it up in a database - the database only has the id, url fragment, the content. the title and te ref-id
The ref-id points to the other page where that is the child of, like ballmachines pointing to knex will be triggerd at /knex/ballmachines.
It also creates the naviagation out of that.

Wait, there is still another thing that makes it 20% cooler - the content is stored in BB-Code and gets parsed to HTML - with a self-written bb-code parser!
the bb-code parser also makes defining tags VERY easy.
This for example will create the [b] tag:

--- Code: ---$bbParser->addTag('b',function($type,$s,$attrs,$bbParser){
        return '<b>'.$bbParser->parse($s).'</b>';
},[],'bold');

--- End code ---
First parameter of addTag is the tag name, so b. The second one is the function that'll get called to parse that tag, the third one is a array of all attributes allowed, the 4th one is help text (not used yet, lol)
So for [url] it looks like this:

--- Code: ---$bbParser->addTag('url',function($type,$s,$attrs,$bbParser){
        if (isset($attrs['url'])) {
                if (filter_var($attrs['url'],FILTER_VALIDATE_URL))
                        return '<a href="'.$attrs['url'].'">'.$bbParser->parse($s).'</a>';
                return $bbParser->returnBB($type,$s,$attrs);
        }
        if (filter_var($s,FILTER_VALIDATE_URL))
                return '<a href="'.$s.'">'.$s.'</a>';
        return $bbParser->returnBB($type,$s,$attrs);
},['url'],'Display URL');

--- End code ---

So yeah, todos:

* GUI way of editing the DB, currently i use phpmyadmin
* comments on each page!
* Add bbCode parser whitelisting/blacklisting
* stuff?
Any thoughts/ideas?

Jim Bauwens:
Sounds like fun!

Spoiler For Spoiler: :devil:

Streetwalrus:
Sounds pretty cool to me. :)

Sorunome:
ha, thanks guys!
I also forgot something in the todo list: when calling $bbParser->parse() i want to add that you can specify which tags get whitelisted/blacklisted, and then use that bb-code parser also for the comments.

Sorunome:
Ok, it is now public! Enjoy!

Note that i still have to program things like user management, commenting etc.

Navigation

[0] Message Index

[#] Next page

Go to full version