蛞蝓-Slugs
ARCHIVED
!注意“归档”
This chapter has not been updated for the current version of Orchard, and has been ARCHIVED.
The slug admin UI shows the first part of the URL as read only and follows that immediately with a textbox that is wide enough to accommodate long slugs.
slug管理UI将URL的第一部分显示为只读,然后立即使用足够宽的文本框来容纳长slu。
We should explain what a slug is and what it's used for right in the admin UI as many users will not be familiar with that notion:
我们应该在管理界面中解释一下slu is是什么以及它用于什么,因为很多用户都不熟悉这个概念:
"A slug is what Orchard uses to build a unique and readable address for your pages. You can usually trust the system to build one for you from the title or you can tweak it to make it shorter or more or less explicit, at your convenience. An example of slug is 'about-us'."
“一个slu is是Orchard用来为你的网页建立一个独特且可读的地址。你通常可以信任系统从你的标题中为你建立一个或者你可以调整它以使它更短或更多或更不明确,在你方便slu about的例子是'关于我们'。“
Validation
验证
-
A slug can't be empty. The slug that we store in the database should never be empty, but the user is allowed to not enter a slug. In that case, we generate one for him (see below).
-
slu is不能为空。我们存储在数据库中的slug永远不应该为空,但允许用户不输入slug。在那种情况下,我们为他生成一个(见下文)。 *
-
A slug can't be more than (some arbitrariness here) 1000 characters, which allows for some reasonable additions such as /json or the first parts of the url without a great risk of hitting IE's 2048 char limit for the URL. Message: "Please keep the slug under a thousand characters."
-
一个slug不能超过(这里有些任意)1000个字符,这允许一些合理的添加,例如/ json或url的第一部分,而不会有很大的风险来达到IE的2048字符串限制。消息:“请将slu the保持在千字以下。” *
-
A slug can have international characters and should conform to the RFC for IRI (International Resource Identifier): RFC 3987, which is supported by all modern browsers. A slug can include slashes (/) but each token between slashes must conform to RFC 3987 and not include any of the following characters: ":", "/", "?", "#", "[", "]", "@", "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=", " ".
-
slug可以具有国际字符,并且应该符合IRI(国际资源标识符)的RFC:[RFC 3987](http://tools.ietf.org/html/rfc3987),所有现代浏览器都支持它。 slug可以包含斜杠(/)但是斜杠之间的每个标记必须符合RFC 3987并且不包括以下任何字符:“:”,“/”,“?”,“\#”,“\ [”,“ \]“,”@“,”\!“,”$“,”&“,”'“,”\(“,”\“”,“\ *”,“\ +”,“,”,“ ;“,”=“,”“。
"Please do not use any of the following characters in your slugs: ":", "?", "#", "[", "]", "@", "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=". No spaces are allowed (please use dashes or underscores instead)."
“请不要在你的slu ::中使用以下任何字符:”:“,”?“,”\#“,”\ [“,”\]“,”@“,”\!“,”$“, “&”,“'”,“\(”,“\”“,”\ *“,”\ +“,”,“,”;“,”=“。不允许使用空格(请使用短划线或下划线)代替)。”
Slug generation
S generation一代
When JavaScript is enabled, we should generate a slug after the title field has been entered. When a character is outside of the range of allowed characters, we should replace them with dashes. The generated slug should be converted to lowercase during generation, but if it's manually entered, we should leave it as is. In other words, we should only generate a slug if it was previously empty.
启用JavaScript后,我们应该在输入标题字段后生成一个slug。当一个字符超出允许的字符范围时,我们应该用短划线替换它们。生成的slug应该在生成期间转换为小写,但如果手动输入,我们应该保持原样。换句话说,如果以前是空的,我们应该只生成一个slug。
When JavaScript is not enabled, the user will have to type a slug himself or leave the field empty. When the form is submitted with an empty slug, we generate one from the title.
如果未启用JavaScript,则用户必须自己键入slug或将该字段留空。当表单提交一个空的slug时,我们从标题中生成一个。
The slug can be changed even after the resource has been created. This is somewhat dangerous because internal and external links to that page might get out of sync as a result, so we should display a warning in that case: "You changed the slug of this page from "{0}" to "{1}", which changes its address. Links to this page may get broken as a result."
即使在创建资源之后,也可以更改slug。这有点危险,因为该页面的内部和外部链接可能因此而不同步,因此我们应该在这种情况下显示警告:“您将此页面的slug从”{0}“更改为”{1} “,这改变了它的地址。这个页面的链接可能因此而被打破。”
Note that we allow forward slashes into the slug, which allows the user to manually introduce some hierarchy even though we don't support parent pages.
请注意,我们允许使用正斜杠进入slug,这允许用户手动引入一些层次结构,即使我们不支持父页面。
The slug prefix is built from the application path and the currently configured routes for the module. For example, if the application URL is "http://mydomain/mysite" and the URL for the resource with slug "my-slug" is "~/pages/my-slug", we prefix the slug input field with "http://mydomain/mysite/pages/".
slug前缀是从应用程序路径和当前配置的模块路由构建的。例如,如果应用程序URL是“http:// mydomain / mysite”,并且具有slug“my-slug”的资源的URL是“〜/ pages / my-slug”,我们在slug输入字段前加上“http” :// MYDOMAIN / mysite的/页/”。
When the generated or manually entered slug is discovered by the server to not be unique, it should be made unique by adding a number after it.
当生成或手动输入的段塞被服务器发现不是唯一的时,应该通过在其后面添加一个数字使其唯一。