Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Friendly URLs instead of IDs #330

Open
garster opened this issue Sep 6, 2019 · 6 comments
Open

Friendly URLs instead of IDs #330

garster opened this issue Sep 6, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@garster
Copy link
Contributor

garster commented Sep 6, 2019

My feature request is similar to or would compliment #308

Previous photo galleries I have used create slugified friendly urls.

For example:

Some Album => www.example.com/some-album
Some Album / Sub Album 1 => www.example.com/some-album/sub-album-1
Some Album / I like Cats & Cocktails => www.example.com/some-album/i-like-cats-and-cocktails

This would make sharing and viewing links much more user friendly. I do see now that the album Id is passes in which is very efficient, but with some slight work this would work too. When and album is created or renamed the parent albums could be looked up and the names slugified, path generated, and stored in the DB. Then the lookup could be on that url-slug field instead of the id.

Laravel has a slug helper, but it may not be advanced enough to handle multiple spaces, and special characters. https://laravel.com/docs/5.8/helpers#method-str-slug

There are others on Packagist. I have seen ones that will do stuff like turn & in and and " - " into "-" instead of "---" (like in "Landmark - 25"=> "landmark-25")
https://packagist.org/?query=slug

Thanks for hearing my suggestion.

@ildyria
Copy link
Member

ildyria commented Sep 6, 2019

What happens in case of name collision?

@kamil4
Copy link
Contributor

kamil4 commented Sep 6, 2019

Exactly. Albums and photos in Lychee don't need to have unique titles. We could, of course, add code to enforce that they be unique, but still...

I think the easiest way for us to implement something like this would be to add an alias column to the albums table, and allow the use of that alias in addition to the numeric album IDs that we already have. The alias would be provided by the user (same way as title or description; pretty much every character should be fine, including /) and would obviously have to be unique.

@ildyria
Copy link
Member

ildyria commented Sep 9, 2019

I would like to also bring up the attention with a possible collision with the (not released yet) page module. :)

@kamil4
Copy link
Contributor

kamil4 commented Sep 9, 2019

Erm, what is the page module? 😃

@ildyria
Copy link
Member

ildyria commented Sep 10, 2019

Well I guess you were not aware that you could add pages & menu to the landing. 😆
I made it a long time ago to be able to add things like : about, contact, portfolio, or even worse, blog posts...

Route::get('/{page}', 'PageController@page');

https://github.com/LycheeOrg/Lychee-Laravel/blob/master/app/Http/Controllers/PageController.php#L40

public function page(Request $request, $page)
	{
		$page = Page::enabled()->where('link', '/' . $page)->first();
		if ($page == null) {
			abort(404);
		}
		$lang = Lang::get_lang(Configs::get_value('lang'));
		$lang['language'] = Configs::get_value('lang');
		$infos = $this->configFunctions->get_pages_infos();
		$title = Configs::get_value('site_title', Config::get('defines.defaults.SITE_TITLE'));
		$menus = Page::menu()->get();
		$contents = $page->content;
		$page_config = array();
		$page_config['show_hosted_by'] = false;
		$page_config['display_socials'] = false;
		return view('page', ['locale' => $lang, 'title' => $title, 'infos' => $infos, 'menus' => $menus, 'contents' => $contents, 'page_config' => $page_config]);
	}

https://github.com/LycheeOrg/Lychee-Laravel/blob/master/app/Page.php
https://github.com/LycheeOrg/Lychee-Laravel/blob/master/app/PageContent.php

@ildyria ildyria added enhancement New feature or request Lychee-Laravel labels Oct 14, 2019
@quentinsf
Copy link

Picking up an old thread... here's another vote for the idea of an alias that could be used to give a friendly URL to an album.

I'm really liking the look of Lychee and would like to migrate to it from other systems where I have shared URLs like '/Architecture' and '/Haddenham-Steam-Rally' with many others, so I want to keep legacy links working as much as I can, without writing lots and lots of nginx redirects :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants