summaryrefslogtreecommitdiff
path: root/wikipedia/views
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2013-08-08 11:38:04 -0700
committerPhilip Chimento <philip@endlessm.com>2013-08-08 11:38:04 -0700
commit90e9940a3d5e3b0cf98a6f264c2382b2e85ccdfc (patch)
tree89855222186d9a0cfa458417f13844f5ccc6b246 /wikipedia/views
parent7123670cff775b331e726e93118ccde066af89b5 (diff)
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]
Diffstat (limited to 'wikipedia/views')
-rw-r--r--wikipedia/views/wikipedia_view.js73
1 files changed, 2 insertions, 71 deletions
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 += "<div id='main'>";
- html += "<section id='main-content'>";
- html += "<header id='header-content'>";
- html += "<h1>" + title + "</h1>";
- html += "</header>";
- html += "<section image_path=" + image_path +" id='inside-content'>";
- html += "<hr class='hr-title'>";
- html += articleHTML;
- html += "</section>";
- html += "</section>";
- html += "</div>";
- return html;
- },
-
- _get_style_sheet_html: function(current_dir, sheets){
- let html = "";
- for(let i = 0; i < sheets.length; i++){
- html += "<link rel='stylesheet' href=" + current_dir + "/css/" + sheets[i] + ">";
- }
- return html;
- },
-
- _get_script_html:function(current_dir, scripts){
- let html = "";
- for(let i = 0; i < scripts.length; i++){
- html += "<script src='" + current_dir + "/js/" + scripts[i] + "'></script>";
- }
- return html;
- },
-
- _get_meta_html:function(){
- let html = "";
- html += "<meta charset='utf-8'>";
- html += "<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>";
- html += "<meta name='description' content=''>";
- html += "<title></title>";
- html += "<meta name='viewport' content='width=device-width'>";
- 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() {