ElkArte Community

Elk Development => Feature Discussion => Exterminated Features => Topic started by: oneduality on January 05, 2018, 12:14:20 pm

Title: SEF URLs .. Yes I know it's been discussed
Post by: oneduality on January 05, 2018, 12:14:20 pm
But rather than awaken an old thread ( https://www.elkarte.net/community/index.php?topic=2565.0 )

I'm surprised the topic is three years old and it's not been implemented honestly, it's pretty common to have that as an option out of the box with most web applications in this day and age. 

I realize it doesn't matter so much for search engines but it matters to people.  I work for a company ( not naming it since I'm not here to promote them ) but we deal with this kind of stuff on a professional level, we build websites, we do marketing and we also do print work.  Our clients want this, they ask about it and they are leery when told it's unimportant.

There's data to back it too, in what we've looked at, traffic tends to be higher when using SEF urls, not necessarily due to search engines but link sharing and the like.  This is because the URL itself can be descriptive in what is behind the link.  This matters when sharing links in e-mail, in print, online.. etc..  It's far more important than nice but throw away features like emoticons

Ultimately I think there's a lot more benefit in human readable urls than people might realize.

I do apologize if there's other more updated threads  but the one I linked seemed to be the most active and it showed up in my search firsts.   I have implemented human readable urls in many of my own pieces of software I've written for clients, but I do always consider it as part of my original design from the start and have been since the late 90s and early 2000s .. it's such a mainstream feature that it always surprises me to not see it.

Aside from that missing feature I think the software is pretty solid, I didn't realize that wasn't there until I adopted the software for my own forum I've been looking to start for several years.

It's my opinion at least that it should be a higher priority, I'd love to start suggesting this software to clients but that being missing would be a no for most of them I know.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: emanuele on January 05, 2018, 03:58:31 pm
Hi oneduality and welcome. :)

The feature is indeed long overdue and didn't get much love over the years because despite a lot of requests, not many have been willing to jump in and code it.
I ported an addon over from SMF (https://github.com/emanuele45/SimpleSEF ) but as you can see, after the initial porting I didn't spend much time working on it (actually I ported it just not to hear people asking for the feature LOL).
A while ago I set up a project for semantic URLs at github:
https://github.com/elkarte/Elkarte/projects/2
it's pretty much empty both because I set it up as a way to see how projects work and because I did it when still working on closing up 1.1. It may be something to consider for 2.0.
I think it will require quite a bit of changes and probably some even "drastic" (think about the fact that now the subject is the subject of the *message*, not of the topic, and that means each and every message in a topic can have a different subject, so in planning this feature we have to decide what to do to have it "done right"), so... it's a bit of work indeed.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: ahrasis on January 05, 2018, 07:17:25 pm
I think most of SEF or similar mods requires only apache rewrite so it is not universal enough for those who use nginx to test or help to develop.[1] It'll be useful if the basis work for both, so it can be tested and developed in both webservers.

However, I am not interested in SEF development since from what I understand, it is not needed by modern SEs.

And since the basic can be found, cloned and developed from the above given github, let those who are interested do that.
Even Split Forum mod that I attempted to port and test with EA requires apache.  :'(
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Allan on January 05, 2018, 07:20:34 pm
Even though it's not a need for proper SEO it still brings a very clean look to a forum, that many people want. 
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Feline on January 05, 2018, 08:17:59 pm
I have rewritten the code (Original Code is Matt Zuba) completely for our Forum Version.
This now run clean and very fast and Google find that very good  ;)

All links for actions, member, board, topics and other are rewitten as example ..

url/index.php?action=search;  ==> url/search/
url/index.php?board=3;  ==> url/board-name/
url/index.php?topic=95.3;#msg27  ==> url/board-name/first-topic-subject/60/#msg27 (20 topics on a page)
url/index.php?action=profile;u=27; ==> url/profile/user-name/
... and mutch more ..

Duplicated names are detected automatically .. so if you have a Topic, User, what else with the same name as any other, the second one becomes a additional dupe number (1..n)
so .. if you have a board with the name "Search", the board is called as /search-1/

Our SEF works very stable over years and is also implemeted in our new forum version..

Fel
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: oneduality on January 05, 2018, 08:22:01 pm
Quote from: emanuele – Hi oneduality and welcome. :)

The feature is indeed long overdue and didn't get much love over the years because despite a lot of requests, not many have been willing to jump in and code it.
I ported an addon over from SMF (https://github.com/emanuele45/SimpleSEF ) but as you can see, after the initial porting I didn't spend much time working on it (actually I ported it just not to hear people asking for the feature LOL).
A while ago I set up a project for semantic URLs at github:
https://github.com/elkarte/Elkarte/projects/2
it's pretty much empty both because I set it up as a way to see how projects work and because I did it when still working on closing up 1.1. It may be something to consider for 2.0.
I think it will require quite a bit of changes and probably some even "drastic" (think about the fact that now the subject is the subject of the *message*, not of the topic, and that means each and every message in a topic can have a different subject, so in planning this feature we have to decide what to do to have it "done right"), so... it's a bit of work indeed.

I absolutely get it, I've not looked through the code base but been a developer for a long long time, but it seems you should be workable..  I'll take a look at it just to get an idea of what's going on, but I won't make any promise I could personally do anything.  I'm already wearing 4-5 hats in my day job that I've not been able to work on my passion projects :) I just think this software is one of the cleanest I've looked at, I like the interface on the back-end and it's feature rich.. so I think the one thing missing is this.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: oneduality on January 05, 2018, 08:29:07 pm
Quote from: Allan – Even though it's not a need for proper SEO it still brings a very clean look to a forum, that many people want.
Quote from: ahrasis – I think most of SEF or similar mods requires only apache rewrite so it is not universal enough for those who use nginx to test or help to develop.[1] It'll be useful if the basis work for both, so it can be tested and developed in both webservers.

However, I am not interested in SEF development since from what I understand, it is not needed by modern SEs.

And since the basic can be found, cloned and developed from the above given github, let those who are interested do that.

It may not be necessary for search engines, it probably never was to be quite honest. But it's good for human friendly urls .. This actually is shown in our analytics for clients we work with and it's been a make or break feature for a lot of them in projects we deploy.  A lot of our clients link things in e-mail, social media, even print material .. People are far less likely to visit a url that looks odd ( index.php?whatever ) .. than a url that makes sense and is self descriptive.

This is becoming more and more true, and it's already a standard feature for most web applications as as a result, so I think it's more important than you'd think.  Not so much for casual things, but for those serious about it, it matters.
Even Split Forum mod that I attempted to port and test with EA requires apache.  :'(
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: oneduality on January 05, 2018, 08:30:15 pm
Quote from: Feline – I have rewritten the code (Original Code is Matt Zuba) completely for our Forum Version.
This now run clean and very fast and Google find that very good  ;)

All links for actions, member, board, topics and other are rewitten as example ..

url/index.php?action=search;  ==> url/search/
url/index.php?board=3;  ==> url/board-name/
url/index.php?topic=95.3;#msg27  ==> url/board-name/first-topic-subject/60/#msg27 (20 topics on a page)
url/index.php?profile=27; ==> url/profile/user-name/
... and mutch more ..

Duplicated names are detected automatically .. so if you have a Topic, User, what else with the same name as any other, the second one becomes a additional dupe number (1..n)
so .. if you have a board with the name "Search", the board is called as /search-1/

Our SEF works very stable over years and is also implemeted in our new forum version..

Fel


Is this a core code mod? that would be the only issue I'd have.  I am very against modifying core code because it makes upgrading extremely difficult. Otherwise, that looks promising :)
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Feline on January 05, 2018, 08:34:09 pm
Quote from: oneduality – Is this a core code mod? that would be the only issue I'd have.  I am very against modifying core code because it makes upgrading extremely difficult. Otherwise, that looks promising :)
No .. this is a custom implementation for our Forum version .. But this can be adapted for similar forums (like ElKarte)

Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: oneduality on January 05, 2018, 08:40:45 pm
Ohh, I didn't realize you were mentioning your forum software on ElkArte's forums .. usually that's frowned upon :) so I assumed it was a customization to ElkArte

Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Feline on January 05, 2018, 08:45:24 pm
Quote from: oneduality – Ohh, I didn't realize you were mentioning your forum software on ElkArte's forums .. usually that's frowned upon :) so I assumed it was a customization to ElkArte
@emanuele known the code .. she is the right person to implement that for elkarte (I think)  ;)
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: oneduality on January 05, 2018, 08:46:45 pm
Quote from: Feline –
Quote from: oneduality – Ohh, I didn't realize you were mentioning your forum software on ElkArte's forums .. usually that's frowned upon :) so I assumed it was a customization to ElkArte
@emanuele known the code .. she is the right person to implement that for elkarte (I think)  ;)


Good point.. I would jump on this myself if I were familiar enough with the code base and had the time, but I'm swamped at work and when I get home I don't think about coding, I think about trying to get back to work on music lol ..
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Feline on January 05, 2018, 08:49:52 pm
Quote from: oneduality – Good point.. I would jump on this myself if I were familiar enough with the code base and had the time, but I'm swamped at work and when I get home I don't think about coding, I think about trying to get back to work on music lol ..
Well .. it's my greates hobby to write good, clean, fast code  ;) 
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: oneduality on January 05, 2018, 08:51:43 pm
Quote from: Feline –
Quote from: oneduality – Good point.. I would jump on this myself if I were familiar enough with the code base and had the time, but I'm swamped at work and when I get home I don't think about coding, I think about trying to get back to work on music lol ..
Well .. it's my greates hobby to write good, clean, fast code  ;) 


I agree, when I started out I worked on all sorts of pet projects, my biggest was work on an AI Chat bot that connected to ICQ/AIM and Yahoo .. I got in legal trouble for that one.. but I had MANY projects.  My job evolved and now I do programming, consulting, systems administration which has me on call 24/7 and also my music which has suffered.. so it's hard to find time to write in my spare time... or rather, hard to find the motivation. And if you're not motivated, you won't write quality code.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: ahrasis on January 05, 2018, 08:52:14 pm
Quote from: Feline – this can be adapted for similar forums (like ElKarte)
Sure. If your are willing to share yours @Feline, I think many of those who are interested can easily port it here.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Feline on January 05, 2018, 09:33:43 pm
Quote from: ahrasis – Sure. If your are willing to share yours @Feline, I think many of those who are interested can easily port it here.
Well .. we are near to release the next Update (version 1.3) because we have optimized many parts, also the SEF engine.
If this availabe, any registered member can download this release and look at our SEF code .. it's only one file and all parts can by called via hooks ...
Ofcourse all (c) notices must stay in any clone ... it's licensed under MPL 1.1

Fel
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: oneduality on January 05, 2018, 09:49:21 pm
Quote from: Feline –
Quote from: ahrasis – Sure. If your are willing to share yours @Feline, I think many of those who are interested can easily port it here.
Well .. we are near to release the next Update (version 1.3) because we have optimized many parts, also the SEF engine.
If this availabe, any registered member can download this release and look at our SEF code .. it's only one file and all parts can by called via hooks ...
Ofcourse all (c) notices must stay in any clone ... it's licensed under MPL 1.1

Fel

It's interesting, though I doubt it will be as simple as that... SEF as an afterthought isn't super simple but it's doable, and unless the architecture is similar it will require heavy modification indeed..

I kind of like how Joomla CMS has done it with their router framework..  but stripping that out and porting it over would be difficult too, and there'd be no help I'm sure.  It's part of the core of the software.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Feline on January 05, 2018, 10:24:21 pm
Well ... elkarte and our Forum is based on the same source .. SMF   :)

Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: ahrasis on January 05, 2018, 10:35:38 pm
Indeed...
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: emanuele on January 06, 2018, 07:57:02 am
It was not meant in the sense I was expecting you to pick it up, sorry for the misunderstanding [1], it was more stating the facts that leaded to not have it implemented in Elk up until now. :)

Quote from: oneduality – I just think this software is one of the cleanest I've looked at, I like the interface on the back-end and it's feature rich.. so I think the one thing missing is this.
Yep, agree, and that's why I proposed it as project to work on. :)
TBH I (as a user) am not very fond on the "friendly" urls, mostly because I'm kind of old school and from time to time I cannot do copy&paste, but I have to type things (on different devices), so for me it's much easier to type 123 rather than a long title, but of course that's just me. :P
Of course if you are interested in picking it up that's all good :P
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: emanuele on January 06, 2018, 08:09:14 am
Quote from: ahrasis – I think most of SEF or similar mods requires only apache rewrite so it is not universal enough for those who use nginx to test or help to develop.
That's why one of the things I would like to evaluate is using a routing php-side, maybe symfony or the routing component of another framework.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: radu81 on January 06, 2018, 08:49:02 am
I've seen this aproach in other forum software, and works fine with Apache or Nginx or other web server
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Frenzie on January 06, 2018, 09:46:30 am
Quote from: oneduality – Ohh, I didn't realize you were mentioning your forum software on ElkArte's forums .. usually that's frowned upon :) so I assumed it was a customization to ElkArte
When relevant (like here) I don't see why it should be frowned upon. The advertisement in the signature is more questionable I suppose.

Quote from: Allan – Even though it's not a need for proper SEO it still brings a very clean look to a forum, that many people want.
I don't give a darn about it looking "clean",[1] but I definitely prefer elkarte.net/community/sef-blablabla over community/index.php?topic=4848 because then I know what it is I'm clicking on.

I despise the rise of URL shorteners. :)

Quote from: emanuele – That's why one of the things I would like to evaluate is using a routing php-side, maybe symfony or the routing component of another framework.
Heck, you could also have something like elk.com/?t=1234&legible-but-totally-unused=sef-urls-yes-i-know-its-been-discussed

Also, while I'm not fond of the idea, with History.push() you could just pretend on the client-side without any server involvement at all.
That's not entirely true, but I think that one or two query string parameters like in Elk are also "clean." It's only on, say, Google that query strings become absurd, unclean creatures. But that doesn't really have anything to do with query strings per se.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: ahrasis on January 08, 2018, 08:47:26 pm
A question for @Feline, does your forum + customized SEF mod work well on Nginx?
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Jorin on January 09, 2018, 01:06:42 am
Quote from: Feline – @emanuele known the code .. she is the right person to implement that for elkarte (I think)  ;)

FYI she is a he.  :D

Okay, sometimes women have beards too. lol
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: live627 on January 09, 2018, 01:15:22 am
esp dwarves (yay LOTR)
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Jorin on January 09, 2018, 01:31:31 am
I love LOTR and all stories that play in Tolkien's worlds! oh, I still have to read the letters to Santa Claus!  O:-)
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Feline on January 09, 2018, 11:33:16 am
Quote from: ahrasis – A question for @Feline, does your forum + customized SEF mod work well on Nginx?
Because I don't have Nginx I can't test it ...

What you need is a mod_rewrite like apache have ..
This is the .htaccess
Code: [Select]
# sef engine
RewriteBase /forum/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Fel
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: ahrasis on January 09, 2018, 08:08:00 pm
That part is quite easy in Nginx. But others, I am not so sure. However, thank you very much for the information.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Frenzie on January 10, 2018, 08:34:10 am
No harder in Lighttpd either. ;)
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Feline on January 10, 2018, 02:02:27 pm
Quote from: ahrasis – That part is quite easy in Nginx. But others, I am not so sure.
Well .. the PHP code itself is very complexe ..
But .. the most entrys can be done with hooks.

Fel
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: hartiberlin on January 17, 2018, 08:56:20 am
Hi Feline, canĀ“t you write the SEF Mod for Elkarte or do you want to keep this just for your own PortaMX forum ?

Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Feline on January 17, 2018, 03:49:14 pm
I don't write code for Elkarte ... only for our Forum version.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: emanuele on August 04, 2018, 10:10:25 am
Let's use that just because it's the first topic that came up from the search.
Today I started[1] playing with semantic urls.

The current progress is this one:
https://github.com/elkarte/Elkarte/compare/development...emanuele45:semantic_urls?expand=1

The general idea is:

The way the code works should be somehow easy I think, I created a function that calls the singleton (yeah, again, I know, I just didn't know where to put the darn stuff, so for the time being I stuffed it in a singleton that looks nicer that $context to me, at least for this kind of things).
The example I used is:
Code: [Select]
'url' => $scripturl . '?action=markasread;sa=all;bi;' . $context['session_var'] . '=' . $context['session_id']
that becomes:
Code: [Select]
'url' => getUrl('action', array('action' => 'markasread', 'sa' => 'all', 'bi', $context['session_var'] => $context['session_id']))
I'm pretty sure purist of speed will frown at the fact it needs a function call... feel free to stick with your buffer rewrite. :P

Of course, this is just the easy part, now the two difficult ones:

And since 2 is massive, I decided to post it here to get some feedback regarding the code, if anyone sees problems or lacks of features, because I would like to avoid having to redo everything two times. O:-)
well, it's not true because the code was laying around since quite a while and it was not even committed, so I've been quite lucky I didn't delete it while doing some cleaning. xD
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Spuds on August 04, 2018, 05:41:37 pm
Quick look I think its good

May want to consider moving the session var and id stuff to the getUrl() function, maybe as a third param done as true/false.  True by default with an false option not to add it (I guess that may be needed somewhere maybe?)
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: emanuele on August 05, 2018, 01:03:27 am
Good point.
Maybe, though, false by default, I think the number cases we do not want session is far greater than when we want it?
I'll try to get some number later.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: emanuele on August 05, 2018, 11:00:14 am
@Spuds https://github.com/elkarte/Elkarte/commit/2cb27b92618654601f2d55cd04f5221d2f8fb579 since we already use "replacements" all over the place, I thought it may work here as well. O:-)
What do you think?
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Spuds on August 05, 2018, 05:38:49 pm
Getting all fancy on me ... I like it !
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: emanuele on August 12, 2018, 11:29:45 am
Any idea why in certain list where the url is sprintf'ed, $scripturl has an strtr to replace single % to %%?
Code: [Select]
'format' => '<a href="' . strtr($scripturl, array('%' => '%%')) . '?action=profile;u=%1$d">%2$s</a>',
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: emanuele on August 13, 2018, 08:02:39 am
I kind of found my answer. It was randomly applied in few places during the very first implementation of createList, but apparently without any real schema: in certain places it was added, in others it was not.
So, unless anyone has any objection, I'm going to drop them all and go for the "without strtr" version.
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: emanuele on September 25, 2018, 09:19:15 am
Okay, few months after I have the prototype up and working locally.
It doesn't come with any configuration yet (not even the "enable") is not yet completed because I replaced only the potentially bot-facing urls in the controllers and subs (still have to touch the template) and is probably buggy, but it's a start.
I went for:
index.php?b/{boardname}-{id}/page-{number}
index.php?t/{subject}-{id}/page-{number}
* index.php?p/{username}-{id}
and then after that a question mark and any other parameter.

It's yet another re-inventing the wheel kind of thing, but... well, it was easier for now to write it rather than learn how to use existing stuff. xD

Here it is the code:
https://github.com/elkarte/Elkarte/compare/development...emanuele45:semantic_urls?expand=1

When the templates will be done I'll send the pull request. If anyone is interested in helping with this, it may do with some testing (and a working example of htaccess to hide the index.php? part would be very helpful! xD), and if you are interested enough to do some coding, you can send PRs to my own repo. ;)
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: emanuele on October 27, 2018, 06:22:28 pm
There:
https://github.com/elkarte/Elkarte/pull/3246

Many things are missing, but at least something is there. xD
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: elk_is_cool on November 05, 2018, 04:37:38 pm
I've been preaching SEF url's for years...its the only reason I keep going back to the not ready for prime time Vanilla software.  If Elk had SEF url's it would be the "bees knees" as I think they say over in jolly ol' England. 

Code: [Select]
# sef engine
RewriteBase /forum/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

This seems to work in cleaning up the URL's to my forum. 
Got rid of: /index.php?PHPSESSID=80b4efc14c62366ebf046e6bd9d6d09d&board=12.0

The URL's are not as good as "/welcome-to-our-forum"  but better then it was!   Is it OK to use this?
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: elk_is_cool on November 05, 2018, 05:04:20 pm
Quote from: Jorin –
Quote from: Feline – @emanuele known the code .. she is the right person to implement that for elkarte (I think)  ;)

FYI she is a he.  :D

That had me confused too.   I was looking at Emanuele's avatar, and thought, if that's a female avatar, we're in trouble!   :o
Title: Re: SEF URLs .. Yes I know it's been discussed
Post by: Jorin on November 06, 2018, 01:27:37 am
Emanuele is male. Read again please.  ;)