summaryrefslogtreecommitdiff
path: root/wikipedia
diff options
context:
space:
mode:
authormattdangerw <mattdangerw@gmail.com>2013-08-07 11:33:15 -0700
committermattdangerw <mattdangerw@gmail.com>2013-08-07 11:33:15 -0700
commitacc2aab8809f62958774b795142d788734784fdd (patch)
treea58079fec85c1049534f9552263dc1dfb70d31df /wikipedia
parent4ddfa5f8d0b12049f1e868da1cd801e3686a2f7f (diff)
parent50d64b4b01d33a36bd0dd5afa8c9c711c1145854 (diff)
Merge pull request #231 from endlessm/issues/230
Modified view pages to load by url
Diffstat (limited to 'wikipedia')
-rw-r--r--wikipedia/PrebuiltArticlesPage.js21
-rw-r--r--wikipedia/views/domain_wiki_view.js2
-rw-r--r--wikipedia/views/wikipedia_view.js7
3 files changed, 26 insertions, 4 deletions
diff --git a/wikipedia/PrebuiltArticlesPage.js b/wikipedia/PrebuiltArticlesPage.js
index 2578648..f5c133b 100644
--- a/wikipedia/PrebuiltArticlesPage.js
+++ b/wikipedia/PrebuiltArticlesPage.js
@@ -15,11 +15,17 @@ const PrebuiltArticlesPage = new Lang.Class({
'Article title',
'Human-readable title for the article to be displayed',
GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT,
+ ''),
+ 'article-uri': GObject.ParamSpec.string('article-uri',
+ 'Article URI',
+ 'Wikipedia URI for the article to be displayed',
+ GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT,
'')
},
_init: function(props) {
this._article_title = null;
+ this._article_uri = null;
this._wiki_view = new WikipediaView.WikipediaView({
expand:true,
@@ -40,8 +46,19 @@ const PrebuiltArticlesPage = new Lang.Class({
set article_title(value) {
this._article_title = value;
+ },
+
+ get article_uri() {
+ return this._article_uri;
+ },
+
+ set article_uri(value) {
+ this._article_uri = value;
if(value !== null && value !== "") {
- this._wiki_view.loadArticleByTitle(this._article_title);
+ this._wiki_view.loadArticleByTitle(this._article_uri, this._article_title);
}
- }
+ },
+
+
+
}); \ No newline at end of file
diff --git a/wikipedia/views/domain_wiki_view.js b/wikipedia/views/domain_wiki_view.js
index 84af542..60bb000 100644
--- a/wikipedia/views/domain_wiki_view.js
+++ b/wikipedia/views/domain_wiki_view.js
@@ -181,7 +181,9 @@ const DomainWikiView = new Lang.Class({
},
set_article_info: function(article){
+ // Note: Must set article title first
this._article_view.article_title = article.title;
+ this._article_view.article_uri = article.uri;
},
transition_page: function(transition_type, page_name){
diff --git a/wikipedia/views/wikipedia_view.js b/wikipedia/views/wikipedia_view.js
index e5762a6..b8aaff0 100644
--- a/wikipedia/views/wikipedia_view.js
+++ b/wikipedia/views/wikipedia_view.js
@@ -61,7 +61,10 @@ const WikipediaView = new Lang.Class({
return html;
},
- loadArticleByTitle: function(title) {
+ loadArticleByTitle: function(url, human_title) {
+ let parts = url.split("/");
+ let suffix = parts[parts.length - 1];
+ let title = decodeURI(suffix.replace("_", " ", 'g'));
let request = Soup.Message.new("GET", getPageURL + title);
this._httpSession.queue_message(request, Lang.bind(this, function(_httpSession, message) {
if(message.status_code !== 200) {
@@ -76,7 +79,7 @@ const WikipediaView = new Lang.Class({
let cur_exec = Utils.get_path_for_relative_path(".");
let image_path = cur_exec + "/web_view/article_images/";
- let documentHTML = this._get_meta_html() + this._get_body_html(articleHTML, title, image_path);
+ let documentHTML = this._get_meta_html() + this._get_body_html(articleHTML, human_title, image_path);
let sheets = new Array("first_load.css", "second_load.css","main.css","wikipedia.css","nolinks.css");
documentHTML = this._get_style_sheet_html(current_dir, sheets) + documentHTML;