Merge pull request #5667 from svbergerem/help-section-routing
Add routes for help sections
This commit is contained in:
commit
e05ae411eb
6 changed files with 82 additions and 11 deletions
|
|
@ -165,6 +165,7 @@ diaspora.yml file**. The existing settings from 0.4.x and before will not work a
|
||||||
* Added keyboard shortcuts r(reshare), m(expand Post), o(open first link in post) [#5602](https://github.com/diaspora/diaspora/pull/5602)
|
* Added keyboard shortcuts r(reshare), m(expand Post), o(open first link in post) [#5602](https://github.com/diaspora/diaspora/pull/5602)
|
||||||
* Dynamically compute minimum and maximum valid year for birthday field [#5639](https://github.com/diaspora/diaspora/pull/5639)
|
* Dynamically compute minimum and maximum valid year for birthday field [#5639](https://github.com/diaspora/diaspora/pull/5639)
|
||||||
* Show hovercard on mentions [#5652](https://github.com/diaspora/diaspora/pull/5652)
|
* Show hovercard on mentions [#5652](https://github.com/diaspora/diaspora/pull/5652)
|
||||||
|
* Make help sections linkable [#5667](https://github.com/diaspora/diaspora/pull/5667)
|
||||||
|
|
||||||
# 0.4.1.2
|
# 0.4.1.2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
app.Router = Backbone.Router.extend({
|
app.Router = Backbone.Router.extend({
|
||||||
routes: {
|
routes: {
|
||||||
|
"help/:section": "help",
|
||||||
|
"help/": "help",
|
||||||
"help": "help",
|
"help": "help",
|
||||||
"contacts": "contacts",
|
"contacts": "contacts",
|
||||||
"conversations": "conversations",
|
"conversations": "conversations",
|
||||||
|
|
@ -36,10 +38,10 @@ app.Router = Backbone.Router.extend({
|
||||||
this.route(/^bookmarklet(?:\?(.*))?/, "bookmarklet");
|
this.route(/^bookmarklet(?:\?(.*))?/, "bookmarklet");
|
||||||
},
|
},
|
||||||
|
|
||||||
help: function() {
|
help: function(section) {
|
||||||
app.help = new app.views.Help();
|
app.help = new app.views.Help();
|
||||||
$("#help").prepend(app.help.el);
|
$("#help").prepend(app.help.el);
|
||||||
app.help.render();
|
app.help.render(section);
|
||||||
},
|
},
|
||||||
|
|
||||||
contacts: function() {
|
contacts: function() {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ app.views.Help = app.views.StaticContentView.extend({
|
||||||
"click .faq-link-sharing" : "sharing",
|
"click .faq-link-sharing" : "sharing",
|
||||||
"click .faq-link-posts-and-posting" : "postsAndPosting",
|
"click .faq-link-posts-and-posting" : "postsAndPosting",
|
||||||
"click .faq-link-tags": "tags",
|
"click .faq-link-tags": "tags",
|
||||||
"click .faq-link-keyboard-shortcuts" : "keyboardShortcuts",
|
"click .faq-link-keyboard-shortcuts" : "keyboardShortcuts"
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize : function() {
|
initialize : function() {
|
||||||
|
|
@ -19,19 +19,19 @@ app.views.Help = app.views.StaticContentView.extend({
|
||||||
get_support_a_tutorials: { tutorials: this.linkHtml("https://diasporafoundation.org/tutorials", Diaspora.I18n.t( 'tutorials' ))},
|
get_support_a_tutorials: { tutorials: this.linkHtml("https://diasporafoundation.org/tutorials", Diaspora.I18n.t( 'tutorials' ))},
|
||||||
get_support_a_wiki: { link: this.linkHtml("https://wiki.diasporafoundation.org/Special:Search", Diaspora.I18n.t( 'wiki' ))},
|
get_support_a_wiki: { link: this.linkHtml("https://wiki.diasporafoundation.org/Special:Search", Diaspora.I18n.t( 'wiki' ))},
|
||||||
get_support_a_irc: { irc: this.linkHtml("https://wiki.diasporafoundation.org/How_We_Communicate#IRC", Diaspora.I18n.t( 'irc' ))},
|
get_support_a_irc: { irc: this.linkHtml("https://wiki.diasporafoundation.org/How_We_Communicate#IRC", Diaspora.I18n.t( 'irc' ))},
|
||||||
get_support_a_hashtag: { question: this.linkHtml("/tags/question", "#question")},
|
get_support_a_hashtag: { question: this.linkHtml("/tags/question", "#question")}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.POSTS_AND_POSTING_SUBS = {
|
this.POSTS_AND_POSTING_SUBS = {
|
||||||
format_text_a: {
|
format_text_a: {
|
||||||
markdown: this.linkHtml("http://diasporafoundation.org/formatting", Diaspora.I18n.t( 'markdown' )),
|
markdown: this.linkHtml("http://diasporafoundation.org/formatting", Diaspora.I18n.t( 'markdown' )),
|
||||||
here: this.linkHtml("http://daringfireball.net/projects/markdown/syntax", Diaspora.I18n.t( 'here' )),
|
here: this.linkHtml("http://daringfireball.net/projects/markdown/syntax", Diaspora.I18n.t( 'here' ))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.TAGS_SUBS = {
|
this.TAGS_SUBS = {
|
||||||
filter_tags_a: {
|
filter_tags_a: {
|
||||||
third_party_tools: this.linkHtml("https://wiki.diasporafoundation.org/Tools_to_use_with_Diaspora", Diaspora.I18n.t( 'third_party_tools' )),
|
third_party_tools: this.linkHtml("https://wiki.diasporafoundation.org/Tools_to_use_with_Diaspora", Diaspora.I18n.t( 'third_party_tools' ))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -51,20 +51,23 @@ app.views.Help = app.views.StaticContentView.extend({
|
||||||
title_sharing: Diaspora.I18n.t( 'sharing.title' ),
|
title_sharing: Diaspora.I18n.t( 'sharing.title' ),
|
||||||
title_tags: Diaspora.I18n.t( 'tags.title' ),
|
title_tags: Diaspora.I18n.t( 'tags.title' ),
|
||||||
title_keyboard_shortcuts: Diaspora.I18n.t( 'keyboard_shortcuts.title' ),
|
title_keyboard_shortcuts: Diaspora.I18n.t( 'keyboard_shortcuts.title' ),
|
||||||
title_miscellaneous: Diaspora.I18n.t( 'miscellaneous.title' ),
|
title_miscellaneous: Diaspora.I18n.t( 'miscellaneous.title' )
|
||||||
};
|
};
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function(){
|
render: function(section){
|
||||||
var section = app.views.Base.prototype.render.apply(this, arguments);
|
var html = app.views.Base.prototype.render.apply(this, arguments);
|
||||||
|
|
||||||
// After render actions
|
// After render actions
|
||||||
this.resetMenu(true);
|
this.resetMenu(true);
|
||||||
this.renderStaticSection("getting_help", "faq_getting_help", this.GETTING_HELP_SUBS);
|
this.renderStaticSection("getting_help", "faq_getting_help", this.GETTING_HELP_SUBS);
|
||||||
|
|
||||||
return section;
|
var elTarget = this.findSection(section);
|
||||||
|
if(elTarget !== null){ $(elTarget).click(); }
|
||||||
|
|
||||||
|
return html;
|
||||||
},
|
},
|
||||||
|
|
||||||
showItems: function(el) {
|
showItems: function(el) {
|
||||||
|
|
@ -107,8 +110,12 @@ app.views.Help = app.views.StaticContentView.extend({
|
||||||
|
|
||||||
menuClicked: function(e) {
|
menuClicked: function(e) {
|
||||||
this.resetMenu();
|
this.resetMenu();
|
||||||
|
|
||||||
$(e.target).hide();
|
$(e.target).hide();
|
||||||
$(e.target).next().show();
|
$(e.target).next().show();
|
||||||
|
|
||||||
|
var data = $(e.target).data('section');
|
||||||
|
app.router.navigate('help/' + data);
|
||||||
},
|
},
|
||||||
|
|
||||||
clearItems: function() {
|
clearItems: function() {
|
||||||
|
|
@ -133,6 +140,18 @@ app.views.Help = app.views.StaticContentView.extend({
|
||||||
this.$('#faq').append(help_section.render().el);
|
this.$('#faq').append(help_section.render().el);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns The section title whose data-section property equals the given query
|
||||||
|
* Returns null if nothing found
|
||||||
|
* @param dataValue Value for the data-section to find
|
||||||
|
* @returns {jQuery}
|
||||||
|
*/
|
||||||
|
findSection: function(data){
|
||||||
|
var res = this.$('a[data-section=' + data + ']');
|
||||||
|
if(res.length === 0){ return null; }
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
|
||||||
gettingHelp: function(e) {
|
gettingHelp: function(e) {
|
||||||
this.renderStaticSection("getting_help", "faq_getting_help", this.GETTING_HELP_SUBS);
|
this.renderStaticSection("getting_help", "faq_getting_help", this.GETTING_HELP_SUBS);
|
||||||
this.menuClicked(e);
|
this.menuClicked(e);
|
||||||
|
|
@ -170,6 +189,6 @@ app.views.Help = app.views.StaticContentView.extend({
|
||||||
|
|
||||||
linkHtml: function(url, text) {
|
linkHtml: function(url, text) {
|
||||||
return "<a href=\"" + url + "\" target=\"_blank\">" + text + "</a>";
|
return "<a href=\"" + url + "\" target=\"_blank\">" + text + "</a>";
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@
|
||||||
"factory",
|
"factory",
|
||||||
"stubView",
|
"stubView",
|
||||||
"exports",
|
"exports",
|
||||||
|
"spyOn",
|
||||||
|
|
||||||
"app",
|
"app",
|
||||||
"Diaspora",
|
"Diaspora",
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,7 @@ Diaspora::Application.routes.draw do
|
||||||
|
|
||||||
# Help
|
# Help
|
||||||
get 'help' => 'help#faq', :as => 'help'
|
get 'help' => 'help#faq', :as => 'help'
|
||||||
|
get 'help/:topic' => 'help#faq'
|
||||||
|
|
||||||
#Protocol Url
|
#Protocol Url
|
||||||
get 'protocol' => redirect("http://wiki.diasporafoundation.org/Federation_Protocol_Overview")
|
get 'protocol' => redirect("http://wiki.diasporafoundation.org/Federation_Protocol_Overview")
|
||||||
|
|
|
||||||
|
|
@ -87,4 +87,51 @@ describe("app.views.Help", function(){
|
||||||
expect(this.view.$el.find('#faq').children().first().hasClass('faq_question_miscellaneous')).toBeTruthy();
|
expect(this.view.$el.find('#faq').children().first().hasClass('faq_question_miscellaneous')).toBeTruthy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("findSection", function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
this.view.render();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return null for an unknown section', function() {
|
||||||
|
expect(this.view.findSection('you_shall_not_pass')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the correct section link for existing sections', function() {
|
||||||
|
var sections = [
|
||||||
|
'account_and_data_management',
|
||||||
|
'aspects',
|
||||||
|
'pods',
|
||||||
|
'keyboard_shortcuts',
|
||||||
|
'tags',
|
||||||
|
'miscellaneous'
|
||||||
|
];
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
_.each(sections, function(section) {
|
||||||
|
var el = self.view.$el.find('a[data-section=' + section + ']');
|
||||||
|
expect(self.view.findSection(section).html()).toBe(el.html());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("menuClicked", function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
this.view.render();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should rewrite the location', function(){
|
||||||
|
var sections = [
|
||||||
|
'account_and_data_management',
|
||||||
|
'miscellaneous'
|
||||||
|
];
|
||||||
|
spyOn(app.router, 'navigate');
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
_.each(sections, function(section) {
|
||||||
|
self.view.$el.find('a[data-section=' + section + ']').trigger('click');
|
||||||
|
expect(app.router.navigate).toHaveBeenCalledWith('help/' + section);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue