Skip to content

Commit 0c5443d

Browse files
Steffen van Bergeremdenschub
authored andcommitted
Make js-routes use compact and camelcase function names
closes #5941
1 parent 1428369 commit 0c5443d

14 files changed

Lines changed: 68 additions & 63 deletions

File tree

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* Added link to diasporafoundation.org to invitation email [#5893](https://github.com/diaspora/diaspora/pull/5893)
3535
* Gracefully handle missing `og:url`s [#5926](https://github.com/diaspora/diaspora/pull/5926)
3636
* Remove private post content from "also commented" mails [#5931](https://github.com/diaspora/diaspora/pull/5931)
37+
* Add a button to follow/unfollow tags to the mobile interface [#5941](https://github.com/diaspora/diaspora/pull/5941)
3738

3839
# 0.5.0.1
3940

app/assets/javascripts/app/helpers/handlebars-helpers.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Handlebars.registerHelper('imageUrl', function(path){
1212
return ImagePaths.get(path);
1313
});
1414

15-
Handlebars.registerHelper('urlTo', function(path_helper, id, data){
15+
Handlebars.registerHelper("urlTo", function(pathHelper, id, data){
1616
if( !data ) {
1717
// only one argument given to helper, mangle parameters
1818
data = id;
19-
return Routes[path_helper+'_path'](data.hash);
19+
return Routes[pathHelper](data.hash);
2020
}
21-
return Routes[path_helper+'_path'](id, data.hash);
21+
return Routes[pathHelper](id, data.hash);
2222
});
2323

2424
Handlebars.registerHelper('linkToAuthor', function(context, block) {
@@ -89,32 +89,32 @@ Handlebars.registerHelper('localTime', function(timestamp) {
8989
return new Date(timestamp).toLocaleString();
9090
});
9191

92-
Handlebars.registerHelper('fmtTags', function(tags) {
92+
Handlebars.registerHelper("fmtTags", function(tags) {
9393
var links = _.map(tags, function(tag) {
94-
return '<a class="tag" href="' + Routes.tag_path(tag) + '">' +
95-
' #' + tag +
96-
'</a>';
97-
}).join(' ');
94+
return "<a class=\"tag\" href=\"" + Routes.tag(tag) + "\">" +
95+
" #" + tag +
96+
"</a>";
97+
}).join(" ");
9898
return new Handlebars.SafeString(links);
9999
});
100100

101-
Handlebars.registerHelper('fmtText', function(text) {
101+
Handlebars.registerHelper("fmtText", function(text) {
102102
return new Handlebars.SafeString(app.helpers.textFormatter(text));
103103
});
104104

105-
Handlebars.registerHelper('isCurrentPage', function(path_helper, id, options){
105+
Handlebars.registerHelper("isCurrentPage", function(pathHelper, id, options){
106106
var currentPage = "/"+Backbone.history.fragment;
107-
if (currentPage === Handlebars.helpers.urlTo(path_helper, id, options.data)) {
107+
if (currentPage === Handlebars.helpers.urlTo(pathHelper, id, options.data)) {
108108
return options.fn(this);
109109
} else {
110110
return options.inverse(this);
111111
}
112112
});
113113

114-
Handlebars.registerHelper('isCurrentProfilePage', function(id, diaspora_handle, options){
115-
var username = diaspora_handle.split("@")[0];
116-
return Handlebars.helpers.isCurrentPage('person', id, options) ||
117-
Handlebars.helpers.isCurrentPage('user_profile', username, options);
114+
Handlebars.registerHelper("isCurrentProfilePage", function(id, diasporaHandle, options){
115+
var username = diasporaHandle.split("@")[0];
116+
return Handlebars.helpers.isCurrentPage("person", id, options) ||
117+
Handlebars.helpers.isCurrentPage("userProfile", username, options);
118118
});
119119

120120
Handlebars.registerHelper('aspectMembershipIndicator', function(contact,in_aspect) {

app/assets/javascripts/app/models/person.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
app.models.Person = Backbone.Model.extend({
44
url: function() {
5-
return Routes.person_path(this.get('guid'));
5+
return Routes.person(this.get("guid"));
66
},
77

88
initialize: function() {

app/assets/javascripts/app/pages/contacts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ app.pages.Contacts = Backbone.View.extend({
8383
update: function() {
8484
$("#aspect_nav .ui-sortable").removeClass("synced");
8585
var data = JSON.stringify({ ordered_aspect_ids: $(this).sortable("toArray", { attribute: "data-aspect-id" }) });
86-
$.ajax(Routes.order_aspects_path(),
86+
$.ajax(Routes.orderAspects(),
8787
{ type: "put", dataType: "text", contentType: "application/json", data: data })
8888
.done(function() { $("#aspect_nav .ui-sortable").addClass("synced"); });
8989
},

app/assets/javascripts/app/pages/profile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ app.pages.Profile = app.views.Base.extend({
7676
}
7777

7878
// a collection is set, this means we want to view photos
79-
var route = this.streamCollection ? 'person_photos_path' : 'person_stream_path';
79+
var route = this.streamCollection ? "personPhotos" : "personStream";
8080
var view = this.streamViewClass ? this.streamViewClass : app.views.Stream;
8181

8282
app.stream = new app.models.Stream(null, {
83-
basePath: Routes[route](app.page.model.get('guid')),
83+
basePath: Routes[route](app.page.model.get("guid")),
8484
collection: this.streamCollection
8585
});
8686
app.stream.fetch();

app/assets/javascripts/app/views/help_view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ app.views.Help = app.views.StaticContentView.extend({
4040
this.CHAT_SUBS = {
4141
add_contact_roster_a: {
4242
toggle_privilege: this.getChatIcons(),
43-
contacts_page: this.linkHtml(Routes.contacts_path(), Diaspora.I18n.t('chat.contacts_page'))
43+
contacts_page: this.linkHtml(Routes.contacts(), Diaspora.I18n.t("chat.contacts_page"))
4444
}
4545
};
4646

app/assets/javascripts/app/views/notification_dropdown_view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ app.views.NotificationDropdown = app.views.Base.extend({
7474

7575
getNotifications: function(){
7676
var self = this;
77-
$.getJSON(Routes.notifications_path(this.getParams()), function(notifications){
77+
$.getJSON(Routes.notifications(this.getParams()), function(notifications){
7878
$.each(notifications, function(){ self.notifications.push(this); });
7979
self.hasMoreNotifs = notifications.length >= self.perPage;
8080
if(self.nextPage){ self.nextPage++; }

app/assets/javascripts/app/views/single-post-viewer/single_post_moderation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ app.views.SinglePostModeration = app.views.Feedback.extend({
4949
createParticipation: function (evt) {
5050
if(evt) { evt.preventDefault(); }
5151
var self = this;
52-
$.post(Routes.post_participation_path(this.model.get("id")), {}, function () {
52+
$.post(Routes.postParticipation(this.model.get("id")), {}, function () {
5353
self.model.set({participation: true});
5454
self.render();
5555
});
@@ -58,7 +58,7 @@ app.views.SinglePostModeration = app.views.Feedback.extend({
5858
destroyParticipation: function (evt) {
5959
if(evt) { evt.preventDefault(); }
6060
var self = this;
61-
$.post(Routes.post_participation_path(this.model.get("id")), { _method: "delete" }, function () {
61+
$.post(Routes.postParticipation(this.model.get("id")), { _method: "delete" }, function () {
6262
self.model.set({participation: false});
6363
self.render();
6464
});

app/assets/javascripts/app/views/stream_post_views.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ app.views.StreamPost = app.views.Post.extend({
119119
createParticipation: function (evt) {
120120
if(evt) { evt.preventDefault(); }
121121
that = this;
122-
$.post(Routes.post_participation_path(this.model.get("id")), {}, function () {
122+
$.post(Routes.postParticipation(this.model.get("id")), {}, function () {
123123
that.model.set({participation: true});
124124
that.render();
125125
});
@@ -128,7 +128,7 @@ app.views.StreamPost = app.views.Post.extend({
128128
destroyParticipation: function (evt) {
129129
if(evt) { evt.preventDefault(); }
130130
that = this;
131-
$.post(Routes.post_participation_path(this.model.get("id")), { _method: "delete" }, function () {
131+
$.post(Routes.postParticipation(this.model.get("id")), { _method: "delete" }, function () {
132132
that.model.set({participation: false});
133133
that.render();
134134
});

app/assets/javascripts/mobile/profile_aspects.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ $(document).ready(function(){
2727

2828
if(selected.hasClass('selected')) {
2929
// remove from aspect
30-
var membership_id = selected.data('membership_id');
30+
var membershipId = selected.data("membership_id");
3131

3232
$.ajax({
33-
url: Routes.aspect_membership_path(membership_id),
34-
type: 'DELETE',
35-
dataType: 'json',
33+
url: Routes.aspectMembership(membershipId),
34+
type: "DELETE",
35+
dataType: "json",
3636
headers: {
37-
'Accept': "application/json, text/javascript, */*; q=0.01"
37+
"Accept": "application/json, text/javascript, */*; q=0.01"
3838
}
3939
}).done(function() {
4040
selected.text("– " + Diaspora.I18n.t('aspect_dropdown.mobile_row_unchecked', {name: selected.data('name')}));
@@ -50,7 +50,7 @@ $(document).ready(function(){
5050
var person_id = $el.data('person-id');
5151

5252
$.ajax({
53-
url: Routes.aspect_memberships_path(),
53+
url: Routes.aspectMemberships(),
5454
data: JSON.stringify({
5555
"person_id": person_id,
5656
"aspect_id": parseInt(selected.val(), 10)

0 commit comments

Comments
 (0)