summaryrefslogtreecommitdiff
path: root/wikipedia
diff options
context:
space:
mode:
authorRory MacQueen <rorymacqueen@gmail.com>2013-08-05 12:42:08 -0700
committerRory MacQueen <rorymacqueen@gmail.com>2013-08-05 12:42:08 -0700
commit56acb550bf132af9c2711a9135c9f2b17306a69c (patch)
tree7fc7625a8b948c364319be9b6dc9fca05ab1edf9 /wikipedia
parentefeab93c981aa75021b227f578c5be4df5f1fc62 (diff)
Dealt with relative paths in wikipedia view
Had to change the way webview loaded the uri so that it can load relative paths [endlessm/eos-sdk#220]
Diffstat (limited to 'wikipedia')
-rw-r--r--wikipedia/utils.js5
-rw-r--r--wikipedia/views/wikipedia_view.js11
2 files changed, 11 insertions, 5 deletions
diff --git a/wikipedia/utils.js b/wikipedia/utils.js
index 0edb6d4..662b2b4 100644
--- a/wikipedia/utils.js
+++ b/wikipedia/utils.js
@@ -47,6 +47,11 @@ function load_file_from_resource(filename) {
return data[0];
}
+function get_uri_for_relative_path(relative_path){
+ let file = Gio.file_new_for_path(relative_path);
+ return file.get_uri();
+}
+
function write_contents_to_file(filename, content){
let file = Gio.file_new_for_path(filename);
file.replace_contents(content, null, false, 0, null);
diff --git a/wikipedia/views/wikipedia_view.js b/wikipedia/views/wikipedia_view.js
index 09ef6fe..77015b7 100644
--- a/wikipedia/views/wikipedia_view.js
+++ b/wikipedia/views/wikipedia_view.js
@@ -5,6 +5,8 @@ const WebKit = imports.gi.WebKit2;
const Utils = imports.utils;
const getPageURL = "http://localhost:3000/getArticleByTitle?title=";
+const PATH_TO_INDEX = "web_view/index.html";
+const PATH_TO_TEMP = "web_view/temp.html";
const WikipediaView = new Lang.Class({
Name: 'EndlessWikipediaView',
@@ -31,15 +33,14 @@ const WikipediaView = new Lang.Class({
let article = JSON.parse(articleJSON);
let articleHTML = article["text"];
let title = article['title'];
- let skeletonHTML = Utils.load_file("views/index.html");
+ let skeletonHTML = Utils.load_file(PATH_TO_INDEX);
skeletonHTML = skeletonHTML + "<div id='wiki_content' name='"+ title +"'>" + articleHTML + "</div>"
- Utils.write_contents_to_file("views/temp.html", skeletonHTML);
-
+ Utils.write_contents_to_file(PATH_TO_TEMP, skeletonHTML);
// TODO: Ask about how we can load directly from HTML. Right now, WebKit can't seem to open
// CSS file correctly. All characters in CSS file are in Chinese
-
+ let temp_uri = Utils.get_uri_for_relative_path(PATH_TO_TEMP)
if(this._is_first_time) {
- this.load_uri("file:///home/endless/checkout/eos-sdk/wikipedia/src/views/temp.html", null);
+ this.load_uri(temp_uri);
this._is_first_time = false;
} else {
this.reload();