1

Topic: The format of the "fancy urls" in 1.3?

Quick question for the developers:
have you decided what the format for the URLs will look like in PunBB 1.3?

/thread-id.html ,  /thread-id-title.html or...?

I'm running a mid-sized phpBB board right now and my current way of rewriting the URLs is messy as hell. If switch to punBB 1.2.12 I'll change the way the URLs are re-written, but I still would like my old phpBB urls to work so I'll end up with two sets of rewriting rules: one for the old links, and one for the new ones. It would be convenient if I could start using the "1.3 look" immediately, so that the method that I use for rewriting the URLs of punbb 1.2.12 will be compatible with the 1.3 way of doing the rewriting.

Re: The format of the "fancy urls" in 1.3?

This is the current state of the rewrite support, but it isn't set in stone. We might very well add, for example, the topic subject to the URL. The idea behind the rewrite support is that it should be easy to extend with your own scheme. This isn't quite true just yet, but it will be.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3

Re: The format of the "fancy urls" in 1.3?

Rickard wrote:

This is the current state of the rewrite support, but it isn't set in stone.

Thanks, very helpful.

The idea behind the rewrite support is that it should be easy to extend with your own scheme. This isn't quite true just yet, but it will be.

That sounds great!

4 (edited by Bâshrat the Sneaky 2006-06-17 10:39)

Re: The format of the "fancy urls" in 1.3?

Rickard wrote:

This is the current state of the rewrite support, but it isn't set in stone. We might very well add, for example, the topic subject to the URL. The idea behind the rewrite support is that it should be easy to extend with your own scheme. This isn't quite true just yet, but it will be.

Then what will happen when a topic's title is changed and the old URI is being used from somewhere else? This is a good thing for news websites, blogs and so on, but not for a forum IMHO.

Perhaps it's wiser to offer two options:
1. disable topic's title in URI and enable renaming of topics
2. enable topic's title in URI and disable renaming of topics

Or perhaps an intermediar option: add topic's title in URI and the topic ID, but ignore it inside punBB. That would simplify the identification of topics and not break the entire system once you've changed a topic's title. Or perhaps this is the way you were planning to do it tongue. In that case, just ignore this post smile wink

Yet Another Happy PunBB Admin!

http://driverpacks.net/

5

Re: The format of the "fancy urls" in 1.3?

There is an option to turn fancy url's on and off in the admin console. The default is off.

Re: The format of the "fancy urls" in 1.3?

have topic title in uri is a good thing ; the title could be in the URI for information but the system only use the id

something like /topic/56-topic-title/ and just use 56 (the id) so when you change topic title there is no problem /topic/56-new-topic-title/

Re: The format of the "fancy urls" in 1.3?

Exactly. The subject can be in the link, but only for SEO and "esthetical" reasons.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: The format of the "fancy urls" in 1.3?

Rickard wrote:

Exactly. The subject can be in the link, but only for SEO and "esthetical" reasons.

And how about UTF-8 encoding text ? Can we use it without any problem in URL definition ?

[no signature]

Re: The format of the "fancy urls" in 1.3?

vnpenguin wrote:

And how about UTF-8 encoding text ? Can we use it without any problem in URL definition ?

Well, I can't imagine there would be any problems with that. It is my intention to make PunBB 1.3 UTF-8 only and if that's the case, I can't very well ignore the fancy urls smile

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: The format of the "fancy urls" in 1.3?

I don't know really what do you mean "fancy urls with UTF-8 text". But in vi.wikipedia.org one uses UTF-8, and I see the URL like :

_http://vi.wikipedia.org/wiki/Th%E1%BB%83_lo%E1%BA%A1i:Tin_h%E1%BB%8Dc

It's not so fancy at all :-)
So I would like to see your solution for this smile Thanks.

[no signature]

Re: The format of the "fancy urls" in 1.3?

I think that's a limitation of UTF-8 in URLs wink
The issue is browers that don't support IDN and users that have turned it off due to spoofing concerns (I know I have it off)

Re: The format of the "fancy urls" in 1.3?

Smartys wrote:

I think that's a limitation of UTF-8 in URLs wink
The issue is browers that don't support IDN and users that have turned it off due to spoofing concerns (I know I have it off)

Yeah, I think too.

But

Rickard wrote:

Well, I can't imagine there would be any problems with that.

So Rickard does he have a magical solution ?

smile

[no signature]

Re: The format of the "fancy urls" in 1.3?

No, it just means that the URL will include the text properly encoded tongue

Re: The format of the "fancy urls" in 1.3?

Ah, I see. Well, that's not something we can "solve". URL encoding is what it is.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

15

Re: The format of the "fancy urls" in 1.3?

why don't save in DB title plus title-url ? when you post, a function "strToUrl" transform the title in a valid url and you store it in the db in title-url

Re: The format of the "fancy urls" in 1.3?

Rickard wrote:

Ah, I see. Well, that's not something we can "solve". URL encoding is what it is.

So why add encoded text into "fancy" url ? Could you give me a sample for this ? I can not imagine a "fancy" url with encoded text sad

[no signature]

Re: The format of the "fancy urls" in 1.3?

vnpenguin wrote:

So why add encoded text into "fancy" url ? Could you give me a sample for this ? I can not imagine a "fancy" url with encoded text sad

Maybe you're right. We could use ASCII only characters in the fancy URLs.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: The format of the "fancy urls" in 1.3?

Yup, it's probably the best way to do it. Look at the Textpattern GPL code, this soft already do this for the articles.

19

Re: The format of the "fancy urls" in 1.3?

Yes, Textpattern does fancy urls rather well.

20 (edited by gog 2006-06-27 08:51)

Re: The format of the "fancy urls" in 1.3?

I need this functionality for one of my projects as well, so if somebody can help mi create a function that handles title -> url conversion it would be great. I've downloaded Textpattern today, and this is what I've found so far (didn't have time to investigate it thoroughly):

in /include/txp_category.php:

    function cat_event_category_create($evname)
    {
        global $txpcfg;
        
        //Prevent non url chars on category names
        include_once txpath.'/lib/classTextile.php';
        $textile = new Textile();
        
        $name = ps('name');        
        $title = doSlash($name);                
        $name = dumbDown($textile->TextileThis(trim(doSlash($name)),1));
        $name = preg_replace("/[^[:alnum:]\-_]/", "", str_replace(" ","-",$name));

        $check = safe_field("name", "txp_category", "name='$name' and type='$evname'");

        if (!$check) {
            if($name) {                
                $q = 
                safe_insert("txp_category", "name='$name', title='$title', type='$evname', parent='root'");
                
                rebuild_tree('root', 1, $evname);
                
                if ($q) cat_category_list(messenger($evname.'_category',$name,'created'));
            } else {
                cat_category_list();
            }
        } else {
            cat_category_list(messenger($evname.'_category',$name,'already_exists'));        
        }
    }

Textile class is located in /lib/classTextile.php and the class constructor and TextileThis method do the following:

    function Textile()
    {
        $this->hlgn = "(?:\<(?!>)|(?<!<)\>|\<\>|\=|[()]+)";
        $this->vlgn = "[\-^~]";
        $this->clas = "(?:\([^)]+\))";
        $this->lnge = "(?:\[[^]]+\])";
        $this->styl = "(?:\{[^}]+\})";
        $this->cspn = "(?:\\\\\d+)";
        $this->rspn = "(?:\/\d+)";
        $this->a = "(?:{$this->hlgn}?{$this->vlgn}?|{$this->vlgn}?{$this->hlgn}?)";
        $this->s = "(?:{$this->cspn}?{$this->rspn}?|{$this->rspn}?{$this->cspn}?)";
        $this->c = "(?:{$this->clas}?{$this->styl}?{$this->lnge}?|{$this->styl}?{$this->lnge}?{$this->clas}?|{$this->lnge}?{$this->styl}?{$this->clas}?)";
        $this->pnct = '[\!"#\$%&\'()\*\+,\-\./:;<=>\?@\[\\\]\^_`{\|}\~]';
        $this->urlch = '[\w"$\-_.+!*\'(),";\/?:@=&%#{}|\\^~\[\]`]';
    }

// -------------------------------------------------------------
    function TextileThis($text, $lite='', $encode='', $noimage='', $strict='', $rel='')
    {
        if ($rel)
           $this->rel = ' rel="'.$rel.'" ';

        $text = $this->incomingEntities($text);
        
        if ($encode) {
            $text = str_replace("x%x%", "&", $text);
            return $text;
        } else {
        
            if(!$strict) {
                $text = $this->fixEntities($text);
                $text = $this->cleanWhiteSpace($text);
            }
    
            $text = $this->getRefs($text);
    
            $text = $this->noTextile($text);
            $text = $this->links($text);
            if (!$noimage) {
                $text = $this->image($text);
            }
            $text = $this->code($text);
            $text = $this->span($text);
            $text = $this->footnoteRef($text);
            $text = $this->glyphs($text);
            $text = $this->retrieve($text);
    
            if (!$lite) {
                $text = $this->lists($text);
                $text = $this->table($text);
                $text = $this->block($text);
            }

                // clean up <notextile>
            $text = preg_replace('/<\/?notextile>/', "", $text);
    
                // turn the temp char back to an ampersand entity
            $text = str_replace("x%x%", "&", $text);
    
                // just to be tidy
            $text = str_replace("<br />", "<br />\n", $text);
    
            return $text;
          }
    }

I need to find what some other functions do (ps, doSlash, dumbDown, safeFiels,..) before I'll be able to comprehend what is exactly going on. The biggest problem, as I see it, is replacing characters with caron, acute, stroke, etc. with the plain letter (without caron, acute, stroke, etc.). And after replacing all the invalid characters, replacing spaces with dashes, and droping other invalid characters (',",\,/, etc.) you can pass the string through PHP's urlencode() function to be safe.

http://www.info-mob.com/forum/ - Croatian forum only, don't bother if you don't speak Croatian :)

21

Re: The format of the "fancy urls" in 1.3?

Anybody interested? smile

http://www.info-mob.com/forum/ - Croatian forum only, don't bother if you don't speak Croatian :)

Re: The format of the "fancy urls" in 1.3?

Try to look at the article creating/saving stage. There are two SQL column, one for the title, and for the the "url-title". Ask on the TXP forum if needed.

23

Re: The format of the "fancy urls" in 1.3?

It's OK, I found the code I was looking for in the Vanilla application:

function CleanupString($InString) {
    $Code = explode(',', '<,>,',&,",À,Á,Â,Ã,Ä,Ä,Å,?,?,?,Æ,Ç,?,?,?,?,?,?,Ð,È,É,Ê,Ë,?,?,?,?,?,?,?,?,?,?,?,Ì,Í,Î,Ï,?,?,?, ?,?,?,?,?,?,?,?,?,?,Ñ,?,?,?,?,Ò,Ó,Ô,Õ,Ö,Ö,Ø,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,Ù,Ú,Û,Ü,?,Ü,?,?,?,?,?,?,Ý,?,?, ?,?,?,Þ,Þ,à,á,â,ã,ä,ä,å,?,?,?,æ,ç,?,?,?,?,?,?,ð,è,é,ê,ë,?,?,?,?,?,?,?,?,?,?,?,?,ì,í,î,ï,?,?,?,?,?,?,?,?,?,?,?,?,?,?,ñ,?,?,?,?,?,ò, ó,ô,õ,ö,ö,ø,?,?,?,?,?,?,?,?,ù,ú,û,ü,?,ü,?,?,?,?,?,?,ý,ÿ,?,?,?,?,þ,ß,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?');
    $Translation = explode(',', ',,,,,A,A,A,A,Ae,A,A,A,A,A,Ae,C,C,C,C,C,D,D,D,E,E,E,E,E,E,E,E,E,G,G,G,G,H,H,I,I,I,I,I,I,I,I,I,IJ,J,K,K,K,K,K,K,N,N,N,N,N,O, O,O,O,Oe,Oe,O,O,O,O,OE,R,R,R,S,S,S,S,S,T,T,T,T,U,U,U,Ue,U,Ue,U,U,U,U,U,W,Y,Y,Y,Z,Z,Z,T,T,a,a,a,a,ae,ae,a,a,a,a,ae,c, c,c,c,c,d,d,d,e,e,e,e,e,e,e,e,e,f,g,g,g,g,h,h,i,i,i,i,i,i,i,i,i,ij,j,k,k,l,l,l,l,l,n,n,n,n,n,n,o,o,o,o,oe,oe,o,o,o,o,oe,r,r,r,s,u,u,u,ue,u,ue, u,u,u,u,u,w,y,y,y,z,z,z,t,ss,ss,A,B,V,G,D,E,YO,ZH,Z,I,Y,K,L,M,N,O,P,R,S,T,U,F,H,C,CH,SH,SCH,Y,Y,E,YU,YA,a,b,v,g,d,e,yo,zh, z,i,y,k,l,m,n,o,p,r,s,t,u,f,h,c,ch,sh,sch,y,y,e,yu,ya');
    $sReturn = $InString;
    $sReturn = str_replace($Code, $Translation, $sReturn);
    $sReturn = urldecode($sReturn);
    $sReturn = preg_replace('/[^A-Za-z0-9 ]/', '', $sReturn);
    $sReturn = str_replace(' ', '-', $sReturn);
    return strtolower(str_replace('--', '-', $sReturn)); 
}

I've added some spaces in the arrays so I doesn brake up the forums layout...

http://www.info-mob.com/forum/ - Croatian forum only, don't bother if you don't speak Croatian :)

24

Re: The format of the "fancy urls" in 1.3?

Paul wrote:

There is an option to turn fancy url's on and off in the admin console. The default is off.

Hi, I've installed 1.2.14 and can't find that option. Should it be under "Options"?

Re: The format of the "fancy urls" in 1.3?

This is a 1.3 feature, its not yet released.