slug

Java code/library for generating slugs (for use in pretty URLs)

怎甘沉沦 提交于 2019-11-27 00:27:25
问题 Web frameworks such as Rails and Django has built-in support for "slugs" which are used to generate readable and SEO-friendly URLs: Slugs in Rails Slugs in Django A slug string typically contains only of the characters a-z , 0-9 and - and can hence be written without URL-escaping (think "foo%20bar"). I'm looking for a Java slug function that given any valid Unicode string will return a slug representation ( a-z , 0-9 and - ). A trivial slug function would be something along the lines of:

How to make Django slugify work properly with Unicode strings?

帅比萌擦擦* 提交于 2019-11-26 23:46:12
What can I do to prevent slugify filter from stripping out non-ASCII alphanumeric characters? (I'm using Django 1.0.2) cnprog.com has Chinese characters in question URLs, so I looked in their code. They are not using slugify in templates, instead they're calling this method in Question model to get permalinks def get_absolute_url(self): return '%s%s' % (reverse('question', args=[self.id]), self.title) Are they slugifying the URLs or not? There is a python package called unidecode that I've adopted for the askbot Q&A forum, it works well for the latin-based alphabets and even looks reasonable

best way to escape and create a slug [duplicate]

…衆ロ難τιáo~ 提交于 2019-11-26 22:59:35
问题 Possible Duplicate: URL Friendly Username in PHP? im somehow confused in using proper functions to escape and create a slug i used this : $slug_title = mysql_real_escape_string()($mtitle); but someone told me not to use it and use urlencode() which one is better for slugs and security as i can see in SO , it inserts - between words : https://stackoverflow.com/questions/941270/validating-a-slug-in-django 回答1: Using either MySQL or URL escaping is not the way to go. Here is an article that does

How can I create a SEO friendly dash-delimited url from a string?

江枫思渺然 提交于 2019-11-26 20:37:29
问题 Take a string such as: In C#: How do I add "Quotes" around string in a comma delimited list of strings? and convert it to: in-c-how-do-i-add-quotes-around-string-in-a-comma-delimited-list-of-strings Requirements: Separate each word by a dash and remove all punctuation (taking into account not all words are separated by spaces.) Function takes in a max length, and gets all tokens below that max length. Example: ToSeoFriendly("hello world hello world", 14) returns "hello-world" All words are

django.db.utils.IntegrityError: UNIQUE constraint failed: rango_category__new.slug

六眼飞鱼酱① 提交于 2019-11-26 20:05:53
问题 I'm learning Django from Tango with Django but I keep getting this error when I type: python manage.py makemigrations rango python manage.py migrate This is the output: django.db.utils.IntegrityError: UNIQUE constraint failed: rango_category__new.slug Models.py: from django.db import models from django.template.defaultfilters import slugify class Category(models.Model): name = models.CharField(max_length=128, unique=True) views = models.IntegerField(default=0) likes = models.IntegerField

How do I create a slug in Django?

左心房为你撑大大i 提交于 2019-11-26 19:16:42
I am trying to create a SlugField in Django. I created this simple model: from django.db import models class Test(models.Model): q = models.CharField(max_length=30) s = models.SlugField() I then do this: >>> from mysite.books.models import Test >>> t=Test(q="aa a a a", s="b b b b") >>> t.s 'b b b b' >>> t.save() >>> t.s 'b b b b' I was expecting b-b-b-b . Buddy You will need to use the slugify function. >>> from django.template.defaultfilters import slugify >>> slugify("b b b b") u'b-b-b-b' >>> You can call slugify automatically by overriding the save method: class Test(models.Model): q =

Generate SEO friendly URLs (slugs)

删除回忆录丶 提交于 2019-11-26 18:36:53
Definition From Wikipedia : A slug is the part of a URL which identifies a page using human-readable keywords. To make the URL easier for users to type, special characters are often removed or replaced as well. For instance, accented characters are usually replaced by letters from the English alphabet; punctuation marks are generally removed; and spaces (which have to be encoded as %20 or +) are replaced by dashes (-) or underscores (_), which are more aesthetically pleasing. Context I developed a photo-sharing website on which users can upload, share and view photos. All pages are generated

Convert non-ASCII characters (umlauts, accents…) to their closest ASCII equivalent (slug creation)

孤街浪徒 提交于 2019-11-26 18:28:41
问题 I am looking for way in JavaScript to convert non- ASCII characters in a string to their closest equivalent, similarly to what the PHP iconv function does. For instance if the input string is Rånades på Skyttis i Ö-vik , it should be converted to Ranades pa skyttis i o-vik . I had a look at phpjs but iconv isn't included. Is it possible to perform such conversion in JavaScript, if so how? 回答1: The easiest way I've found: var str = "Rånades på Skyttis i Ö-vik"; var combining = /[\u0300-\u036F]

URL Slugify algorithm in C#?

杀马特。学长 韩版系。学妹 提交于 2019-11-26 18:15:42
So I have searched and browsed through the slug tag on SO and only found two compelling solution: Slugify and Character Transliteration in C# How to convert super- or subscript to normal text in C# Which are but partial solution to the problem. I could manually code this up myself but I'm surprised that there isn't already a solution out there yet. So, is there a slugify alrogithm implementation in C# and/or .NET that properly address latin characters, unicode and various other language issues properly? Marcel http://predicatet.blogspot.com/2009/04/improved-c-slug-generator-or-how-to.html

Using slugs in codeigniter

痴心易碎 提交于 2019-11-26 16:05:04
问题 I have heard of people using slugs for generating clean urls. I have no idea how it works. Currently i have a codeigniter site which generates url's like this www.site.com/index.php/blog/view/7 From what i understand by maintaining a slug field it is possible to achieve urls like www.site.com/index.php/blog/view/once-upon-a-time How is this done? Especially in reference to codeigniter? 回答1: I just store the slugs in my database table, in a column called slug , then find a post with the slug,