From 90e9940a3d5e3b0cf98a6f264c2382b2e85ccdfc Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 8 Aug 2013 11:38:04 -0700 Subject: Do not build Wikipedia HTML in WikipediaView In order to avoid making Soup requests which trigger the crasher, literally load the response received from the node.js server. Remove all code that builds the HTML. [endlessm/eos-sdk#253] --- wikipedia/PrebuiltArticlesPage.js | 2 +- wikipedia/views/wikipedia_view.js | 73 ++------------------------------------- 2 files changed, 3 insertions(+), 72 deletions(-) (limited to 'wikipedia') diff --git a/wikipedia/PrebuiltArticlesPage.js b/wikipedia/PrebuiltArticlesPage.js index f5c133b..933e3b4 100644 --- a/wikipedia/PrebuiltArticlesPage.js +++ b/wikipedia/PrebuiltArticlesPage.js @@ -55,7 +55,7 @@ const PrebuiltArticlesPage = new Lang.Class({ set article_uri(value) { this._article_uri = value; if(value !== null && value !== "") { - this._wiki_view.loadArticleByTitle(this._article_uri, this._article_title); + this._wiki_view.loadArticleByTitle(this._article_uri); } }, diff --git a/wikipedia/views/wikipedia_view.js b/wikipedia/views/wikipedia_view.js index da4f942..f4a4500 100644 --- a/wikipedia/views/wikipedia_view.js +++ b/wikipedia/views/wikipedia_view.js @@ -22,7 +22,6 @@ const WikipediaView = new Lang.Class({ Extends: WebKit.WebView, _init: function(params) { - this._httpSession = new Soup.Session(); this.parent(params); // For debugging //let settings = this.get_settings(); @@ -31,79 +30,11 @@ const WikipediaView = new Lang.Class({ this.connect('context-menu', Lang.bind(this, function(){return true})); }, - _get_body_html:function(articleHTML, title, image_path){ - let html = ""; - html += "
"; - html += "
"; - html += "
"; - html += "

" + title + "

"; - html += "
"; - html += "
"; - html += "
"; - html += articleHTML; - html += "
"; - html += "
"; - html += "
"; - return html; - }, - - _get_style_sheet_html: function(current_dir, sheets){ - let html = ""; - for(let i = 0; i < sheets.length; i++){ - html += ""; - } - return html; - }, - - _get_script_html:function(current_dir, scripts){ - let html = ""; - for(let i = 0; i < scripts.length; i++){ - html += ""; - } - return html; - }, - - _get_meta_html:function(){ - let html = ""; - html += ""; - html += ""; - html += ""; - html += ""; - html += ""; - return html; - }, - - loadArticleByTitle: function(url, human_title) { + loadArticleByTitle: function(url) { 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) { - print(message.status_code); - return; - } - let articleJSON = request.response_body.data; - let article = JSON.parse(articleJSON); - let articleHTML = article["text"]; - let title = article['title']; - let current_dir = Endless.getCurrentFileDir(); - - let image_path = this._getArticleImagesPath(); - - 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; - - let scripts = new Array("jquery-min.js", "main.js"); - documentHTML = documentHTML + this._get_script_html(current_dir, scripts); - - let temp_uri = Utils.write_contents_to_temp_file("wiki.html", documentHTML); - // TODO: Ask about how we can load directly from HTML using load_html. - // Right now, this doesn't work, regardless of what we put in for base_uri - this.load_uri(temp_uri); - })); + this.load_uri(getPageURL + title); }, _getArticleImagesPath: function() { -- cgit v1.2.3