Commit a216a52c authored by Cédric Bellegarde's avatar Cédric Bellegarde

Split Readability.js

parent 4beaf6c3
Pipeline #37425 passed with stage
in 15 minutes
......@@ -1835,23 +1835,3 @@ var uri = {
scheme: loc.protocol.substr(0, loc.protocol.indexOf(":")),
pathBase: loc.protocol + "//" + loc.host + loc.pathname.substr(0, loc.pathname.lastIndexOf("/") + 1)
};
if (typeof document !== 'undefined') {
if (isProbablyReaderable == true) {
var documentClone = document.cloneNode(true);
reader = new Readability(uri, documentClone);
article = reader.parse();
var previous_title = document.title;
alert("@EOLIE_READER@".concat(article.content));
document.title=previous_title;
}
else {
reader = new Readability(uri, document);
if (reader.isProbablyReaderable(false)) {
var isProbablyReaderable=true;
var previous_title = document.title;
alert("@EOLIE_READERABLE@");
document.title=previous_title;
}
}
}
if (typeof document !== 'undefined') {
reader = new Readability(uri, document);
if (reader.isProbablyReaderable(false)) {
var previous_title = document.title;
alert("@EOLIE_READERABLE@");
document.title=previous_title;
}
}
if (typeof document !== 'undefined') {
var documentClone = document.cloneNode(true);
reader = new Readability(uri, documentClone);
article = reader.parse();
var previous_title = document.title;
alert("@EOLIE_READER@".concat(article.content));
document.title=previous_title;
}
......@@ -10,6 +10,8 @@
<file compressed="true">error.css</file>
<file compressed="true">Extensions.js</file>
<file compressed="true">Readability.js</file>
<file compressed="true">Readability_check.js</file>
<file compressed="true">Readability_get.js</file>
<file compressed="true" preprocess="xml-stripblanks">AdblockMenu.ui</file>
<file compressed="true" preprocess="xml-stripblanks">BookmarkEdit.ui</file>
<file compressed="true" preprocess="xml-stripblanks">BookmarkRatingWidget.ui</file>
......
......@@ -613,8 +613,14 @@ class ToolbarTitle(Gtk.Bin):
if view.reading:
view.stop_reading()
else:
view.webview.run_javascript_from_gresource(
"/org/gnome/Eolie/Readability.js", None, None)
js1 = Gio.File.new_for_uri(
"resource:///org/gnome/Eolie/Readability.js")
js2 = Gio.File.new_for_uri(
"resource:///org/gnome/Eolie/Readability_get.js")
(status, content1, tags) = js1.load_contents()
(status, content2, tags) = js2.load_contents()
script = content1.decode("utf-8") + content2.decode("utf-8")
view.webview.run_javascript(script, None, None)
return True
def _on_indicator2_press(self, eventbox, event):
......
......@@ -98,8 +98,9 @@ class View(Gtk.Overlay):
"""
Destroy reading view
"""
self.__reading_view.destroy()
self.__reading_view = None
if self.__reading_view is not None:
self.__reading_view.destroy()
self.__reading_view = None
def set_window(self, window):
"""
......
......@@ -10,7 +10,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from gi.repository import GLib, WebKit2
from gi.repository import GLib, Gio, WebKit2
from urllib.parse import urlparse
......@@ -108,8 +108,14 @@ class WebViewLoadSignals:
popup.destroy()
self.__popups = []
elif event == WebKit2.LoadEvent.FINISHED:
self.run_javascript_from_gresource(
"/org/gnome/Eolie/Readability.js", None, None)
js1 = Gio.File.new_for_uri(
"resource:///org/gnome/Eolie/Readability.js")
js2 = Gio.File.new_for_uri(
"resource:///org/gnome/Eolie/Readability_check.js")
(status, content1, tags) = js1.load_contents()
(status, content2, tags) = js2.load_contents()
script = content1.decode("utf-8") + content2.decode("utf-8")
self.run_javascript(script, None, None)
if webview.get_mapped() and not webview.view.popover:
self.__update_toolbars(event)
......@@ -134,9 +140,8 @@ class WebViewLoadSignals:
# Give focus to url bar
self._window.toolbar.title.start_search()
self._window.toolbar.title.show_indicator(Indicator.NONE)
# Turn off reading mode if needed
if self._window.container.current.reading:
self._window.container.current.switch_read_mode()
# Turn off reading mode
self._window.container.current.stop_reading()
self._window.toolbar.title.progress.show()
elif event == WebKit2.LoadEvent.COMMITTED:
profile = name_from_profile_id(self.profile)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment