summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRory MacQueen <rorymacqueen@gmail.com>2013-08-30 12:56:56 -0700
committerRory MacQueen <rorymacqueen@gmail.com>2013-09-03 09:28:53 -0700
commitd64a015003167262875aec3aed7a5ffe64c0882b (patch)
tree4e56dc1222099a8971c93efa734ab9708b8bd529
parent0837dd9c1a8c7ed772bd1f763c9e8e70cc31cf4f (diff)
Allowed links in domain specific apps
These are the changes to the wikipedia SDK to allow for certain showable links in the domain specific apps. The JSON file will specify which links can be clickable across all articles. [endlessm/eos-sdk#282]
-rw-r--r--wikipedia/PrebuiltArticlesPage.js6
-rw-r--r--wikipedia/PrebuiltWikipediaApplication.js5
-rw-r--r--wikipedia/WikipediaApplication.js7
-rw-r--r--wikipedia/WikipediaWebView.js7
-rw-r--r--wikipedia/models/domain_wiki_model.js8
-rw-r--r--wikipedia/presenters/domain_wiki_presenter.js19
-rw-r--r--wikipedia/views/domain_wiki_view.js4
7 files changed, 45 insertions, 11 deletions
diff --git a/wikipedia/PrebuiltArticlesPage.js b/wikipedia/PrebuiltArticlesPage.js
index 0d0491b..756fee6 100644
--- a/wikipedia/PrebuiltArticlesPage.js
+++ b/wikipedia/PrebuiltArticlesPage.js
@@ -30,7 +30,7 @@ const PrebuiltArticlesPage = new Lang.Class({
this._wiki_view = new EndlessWikipedia.WikipediaWebView({
expand:true,
hide_links:true
- }, []);
+ });
this.parent(props);
@@ -41,6 +41,10 @@ const PrebuiltArticlesPage = new Lang.Class({
context.add_class(EndlessWikipedia.STYLE_CLASS_ARTICLES_PAGE);
},
+ setShowableLinks: function(linked_articles){
+ this._wiki_view.setShowableLinks(linked_articles);
+ },
+
get article_title() {
return this._article_title;
},
diff --git a/wikipedia/PrebuiltWikipediaApplication.js b/wikipedia/PrebuiltWikipediaApplication.js
index d6e2e5b..dcfcfd4 100644
--- a/wikipedia/PrebuiltWikipediaApplication.js
+++ b/wikipedia/PrebuiltWikipediaApplication.js
@@ -21,7 +21,8 @@ const PrebuiltWikipediaApplication = new Lang.Class({
vfunc_startup: function() {
this.parent();
this._domain_wiki_view = new DomainWikiView.DomainWikiView(this);
- let filename = this.application_uri;
- this._domain_wiki_presenter = new DomainWikiPresenter.DomainWikiPresenter(this._domain_wiki_model, this._domain_wiki_view, filename);
+ let app_filename = this.application_uri;
+ let linked_articles_filename = this.linked_articles_uri;
+ this._domain_wiki_presenter = new DomainWikiPresenter.DomainWikiPresenter(this._domain_wiki_model, this._domain_wiki_view, app_filename, linked_articles_filename);
}
});
diff --git a/wikipedia/WikipediaApplication.js b/wikipedia/WikipediaApplication.js
index 152f770..e932ada 100644
--- a/wikipedia/WikipediaApplication.js
+++ b/wikipedia/WikipediaApplication.js
@@ -33,6 +33,13 @@ const WikipediaApplication = new Lang.Class({
'Application Base Path',
'Path to base directory where execution began',
GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY,
+ ''),
+
+ // resource:// URI for the linked articles JSON file
+ 'linked-articles-uri': GObject.ParamSpec.string('linked-articles-uri',
+ 'Linked articles file URI',
+ 'URI for the data file describing which articles can have their links shown',
+ GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY,
'')
},
diff --git a/wikipedia/WikipediaWebView.js b/wikipedia/WikipediaWebView.js
index 63e85e6..c942fbd 100644
--- a/wikipedia/WikipediaWebView.js
+++ b/wikipedia/WikipediaWebView.js
@@ -36,7 +36,7 @@ const WikipediaWebView = new Lang.Class({
false)
},
- _init: function(params, links_to_show) {
+ _init: function(params) {
this.parent(params);
// For debugging
//let settings = this.get_settings();
@@ -44,13 +44,16 @@ const WikipediaWebView = new Lang.Class({
//this.set_settings(settings);
this.connect('context-menu', Lang.bind(this, function(){return true}));
- this._links_to_show = links_to_show;
this.connect('decide-policy',
Lang.bind(this, this._onNavigation));
this.connect('load-changed',
Lang.bind(this, this._onLoadChange));
},
+ setShowableLinks: function(linked_articles){
+ this._links_to_show = linked_articles;
+ },
+
_getFullURL: function(base_url, params){
let full_url = base_url;
for(let key in params){
diff --git a/wikipedia/models/domain_wiki_model.js b/wikipedia/models/domain_wiki_model.js
index a387ff9..cb9071b 100644
--- a/wikipedia/models/domain_wiki_model.js
+++ b/wikipedia/models/domain_wiki_model.js
@@ -18,6 +18,14 @@ const DomainWikiModel = new Lang.Class({
this.parent(params);
},
+ setLinkedArticles:function(articles){
+ this._linked_articles = articles;
+ },
+
+ getLinkedArticles:function(){
+ return this._linked_articles;
+ },
+
//categories should be a list of category models, already populated with article models.
addCategories: function(categories){
this._categories = categories;
diff --git a/wikipedia/presenters/domain_wiki_presenter.js b/wikipedia/presenters/domain_wiki_presenter.js
index b6b432a..2ddaa5d 100644
--- a/wikipedia/presenters/domain_wiki_presenter.js
+++ b/wikipedia/presenters/domain_wiki_presenter.js
@@ -18,21 +18,23 @@ const DomainWikiPresenter = new Lang.Class({
Name: "DomainWikiPresenter",
Extends: GObject.Object,
- _init: function(model, view, filename) {
+ _init: function(model, view, app_filename, linked_articles_filename) {
this._domain_wiki_model = model;
this._domain_wiki_view = view;
this._domain_wiki_view.set_presenter(this)
this._domain_wiki_view.connect('category-chosen', Lang.bind(this, this._onCategoryClicked));
this._domain_wiki_view.connect('article-chosen', Lang.bind(this, this._onArticleClicked));
- this.initFromJsonFile(filename);
+ this.initAppInfoFromJsonFile(app_filename);
+ this.initPageRankFromJsonFile(linked_articles_filename);
- let categories = this._domain_wiki_model.getCategories();
+ this._domain_wiki_view.set_categories(this._domain_wiki_model.getCategories());
- this._domain_wiki_view.set_categories(categories);
+ let linked_articles = this._domain_wiki_model.getLinkedArticles();
+ let to_show = linked_articles["app_articles"].concat(linked_articles["extra_linked_articles"]);
+ this._domain_wiki_view.set_showable_links(to_show);
},
-
initArticleModels: function(articles) {
let _articles = new Array();
for(let i = 0; i < articles.length; i++) {
@@ -44,7 +46,12 @@ const DomainWikiPresenter = new Lang.Class({
return _articles;
},
- initFromJsonFile: function(filename) {
+ initPageRankFromJsonFile: function(filename){
+ let articles = JSON.parse(Utils.load_file_from_resource(filename));
+ this._domain_wiki_model.setLinkedArticles(articles);
+ },
+
+ initAppInfoFromJsonFile: function(filename) {
let app_content = JSON.parse(Utils.load_file_from_resource(filename));
this._lang_code = filename.substring(0, 2);
let categories = app_content['categories'];
diff --git a/wikipedia/views/domain_wiki_view.js b/wikipedia/views/domain_wiki_view.js
index a44eaa2..29f638a 100644
--- a/wikipedia/views/domain_wiki_view.js
+++ b/wikipedia/views/domain_wiki_view.js
@@ -192,6 +192,10 @@ const DomainWikiView = new Lang.Class({
this._front_page.setCategories(categories);
},
+ set_showable_links: function(linked_articles){
+ this._article_view.setShowableLinks(linked_articles);
+ },
+
_onCategoryClicked: function(page, title, index) {
this.emit('category-chosen', title, index);
},