Skip to content

Commit

Permalink
[#1506][js][s]: Warn on very long URL slugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
teajaymars committed Mar 1, 2012
1 parent fd77374 commit 4a74dbf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ckan/public/css/style.css
Expand Up @@ -1115,6 +1115,12 @@ a.url-edit {
font-weight: normal;
margin-left: 10px;
}
p.url-is-long {
color: #600;
display: none;
font-size: 11px;
font-weight: bold;
}


/* ===================== */
Expand Down
7 changes: 7 additions & 0 deletions ckan/public/scripts/application.js
Expand Up @@ -136,6 +136,7 @@ CKAN.View.UrlEditor = Backbone.View.extend({
this.urlSuffix = $('.js-url-suffix');
this.urlInput = $('.js-url-input');
this.validMsg = $('.js-url-is-valid');
this.lengthMsg = $('.url-is-long');
this.lastTitle = "";
this.disableTitleChanged = false;

Expand Down Expand Up @@ -226,6 +227,12 @@ CKAN.View.UrlEditor = Backbone.View.extend({
self.checkSlugIsValid(slug);
}, 200);
}
if (slug.length>20) {
this.lengthMsg.show();
}
else {
this.lengthMsg.hide();
}
},

checkSlugIsValid: function(slug) {
Expand Down
1 change: 1 addition & 0 deletions ckan/templates/group/new_group_form.html
Expand Up @@ -22,6 +22,7 @@ <h2>Errors in form</h2>
<span class="js-url-text url-text">${h.url(controller='group', action='index')+'/'}<span class="js-url-viewmode js-url-suffix">&nbsp;</span><a href="#" class="url-edit js-url-viewmode">(edit)</a></span>
<input style="display: none;" id="name" maxlength="100" name="name" type="text" class="url-input js-url-editmode js-url-input" value="${data.get('name', '')}" />
<p class="js-url-is-valid">&nbsp;</p>
<p class="url-is-long">Warning: URL is very long. Consider changing it to something shorter.</p>
</dd>
<dd style="display: none;" class="js-url-editmode instructions basic">2+ chars, lowercase, using only 'a-z0-9' and '-_'</dd>
<dd class="field_error" py:if="errors.get('name', '')">${errors.get('name', '')}</dd>
Expand Down
1 change: 1 addition & 0 deletions ckan/templates/package/new_package_form.html
Expand Up @@ -45,6 +45,7 @@ <h2>Errors in form</h2>
<span class="url-text">${h.url(controller='package', action='index')+'/'}<span class="js-url-viewmode js-url-suffix">&nbsp;</span><a href="#" class="url-edit js-url-viewmode">(edit)</a></span>
<input style="display: none;" id="name" maxlength="100" name="name" type="text" class="url-input js-url-editmode js-url-input" value="${data.get('name', '')}" />
<p class="js-url-is-valid">&nbsp;</p>
<p class="url-is-long">Warning: URL is very long. Consider changing it to something shorter.</p>
</dd>
<dd style="display: none;" class="js-url-editmode name-instructions basic">2+ characters, lowercase, using only 'a-z0-9' and '-_'</dd>
<dd class="js-url-editmode name-instructions field_error" py:if="errors.get('name', '')">${errors.get('name', '')}</dd>
Expand Down

0 comments on commit 4a74dbf

Please sign in to comment.