Commit 74536c6a authored by anonym's avatar anonym
Browse files

tails-documentation: rewrite in Python + use WebKit for display.

... instead of using the Tor Browser: since version 7.0.8 it fails to
render local pages (like our docs) due to #14962.

Refs: #14962
parent 2be84073
#! /bin/sh
if [ $# -ge 1 ]; then
PAGE="$1"
else
PAGE='index'
fi
WIKI_ROOT='/usr/share/doc/tails/website'
LANG_CODE="`echo ${LANG} | head -c 2`"
if [ -r "${WIKI_ROOT}/${PAGE}.${LANG_CODE}.html" ]; then
FILE="${PAGE}.${LANG_CODE}.html"
elif [ -r "${WIKI_ROOT}/${PAGE}.en.html" ]; then
FILE="${PAGE}.en.html"
else
FILE="${PAGE}.html"
fi
if [ -n "${2}" ]; then
FILE="${FILE}#${2}"
fi
export TOR_BROWSER_SKIP_OFFLINE_WARNING=yes
exec /usr/local/bin/tor-browser "file://${WIKI_ROOT}/${FILE}"
#!/usr/bin/env python3
import gettext
import gi
import locale
import os
import os.path
import sys
import tailsgreeter.gui
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk # NOQA: E402
gi.require_version('WebKit2', '4.0')
from gi.repository import WebKit2 # NOQA: E402
# We'll only use a single translation, "Tails documentation", which
# already is translated for the launcher. For this reason, this script
# is not managed by `refresh-translations`.
gettext.textdomain('tails')
# The browser from the Greeter is good as-is, but a button for
# navigating backwards in the history would be nice.
class DocumentationWindow(tailsgreeter.gui.GreeterHelpWindow):
def _build_ui(self):
super(DocumentationWindow, self)._build_ui()
# The super class' headerbar is not exposed as an instance
# variable, but we need it!
headerbar = next(child for child in self.get_children() \
if isinstance(child, Gtk.HeaderBar))
back_button = Gtk.Button('←')
back_button.connect("clicked", lambda x: self.webview.go_back())
headerbar.pack_start(back_button)
back_button.show()
self.webview.connect(
"load-changed",
lambda webview, e: back_button.set_visible(webview.can_go_back())
)
# Main
try:
page = sys.argv[1]
except IndexError:
page = 'getting_started'
wiki_path = '/usr/share/doc/tails/website'
lang_code = os.getenv('LANG', 'en')[0:2]
trials = [
os.path.join(wiki_path, page + code + ".html")
for code in ['.' + lang_code, '.en', '']
]
try:
uri = 'file://' + next(trial for trial in trials if os.path.isfile(trial))
except StopIteration:
sys.exit('error: could not find the requested documentation page')
if '..' in uri.split(os.sep):
sys.exit('error: cannot escape from {}'.format(wiki_path))
helpwindow = DocumentationWindow(uri)
helpwindow.connect("delete-event", Gtk.main_quit)
helpwindow.window.set_title(gettext.gettext('Tails documentation'))
helpwindow.show()
Gtk.main()
@product @doc
Feature: Tails documentation
Scenario: The Tails documentation launcher on the desktop works
Given I have started Tails from DVD without network and logged in
When I double-click on the Tails documentation launcher on the desktop
Then the documentation viewer opens the "Getting started" page
Scenario: The Report an Error launcher will open the support documentation
Given I have started Tails from DVD without network and logged in
When I double-click on the Report an Error launcher on the desktop
Then the support documentation page opens in Tor Browser
Then the documentation viewer opens the "Support" page
......@@ -9,7 +9,7 @@ Feature: Localization
Given I have started Tails from DVD without network and stopped at Tails Greeter's login screen
And I log in to a new session in German
When I double-click on the Report an Error launcher on the desktop
Then the support documentation page opens in Tor Browser
Then the documentation viewer opens the "Support" page
#11711
@fragile
......
......@@ -94,21 +94,25 @@ Then /^the VirtualBox guest modules are available$/ do
"The vboxguest module is not available.")
end
Then /^the support documentation page opens in Tor Browser$/ do
Then /^the documentation viewer opens the "(Support|Getting started)" page$/ do |page|
if @language == 'German'
expected_title = 'Tails - Hilfe & Support'
expected_heading = 'Die Dokumentation durchsuchen'
expected_title = 'Tails-Dokumentation'
if page == 'Support'
expected_heading = 'Die Dokumentation durchsuchen'
else
page = 'Einen Fehler gefunden?'
end
else
expected_title = 'Tails - Support'
expected_heading = 'Search the documentation'
expected_title = 'Tails documentation'
if page == 'Support'
expected_heading = 'Search the documentation'
else
expected_heading = 'Found a bug?'
end
end
step "\"#{expected_title}\" has loaded in the Tor Browser"
headings = @torbrowser
.child(expected_title, roleName: 'document frame')
.children(roleName: 'heading')
assert(
headings.any? { |heading| heading.text == expected_heading }
)
app = Dogtail::Application.new('tails-documentation')
app.child(expected_title, roleName: 'frame', recursive: false)
app.child(expected_heading, roleName: 'heading')
end
Given /^I plug and mount a USB drive containing a sample PNG$/ do
......
......@@ -727,11 +727,9 @@ end
When /^I double-click on the (Tails documentation|Report an Error) launcher on the desktop$/ do |launcher|
image = 'Desktop' + launcher.split.map { |s| s.capitalize } .join + '.png'
info = xul_application_info('Tor Browser')
# Sometimes the double-click is lost (#12131).
retry_action(10) do
@screen.wait_and_double_click(image, 10) if $vm.execute("pgrep --uid #{info[:user]} --full --exact '#{info[:cmd_regex]}'").failure?
step 'the Tor Browser has started'
@screen.wait_and_double_click(image, 10) if $vm.execute("pgrep --uid #{LIVE_USER} --full --full tails-documentation").failure?
end
end
......
......@@ -99,13 +99,6 @@ Feature: Browsing the web using the Tor Browser
When I open the address "file:///tmp/synaptic.html" in the Tor Browser
Then I do not see "TorBrowserSynapticManual.png" after at most 5 seconds
@doc
Scenario: The Tails documentation launcher on the desktop works
Given I have started Tails from DVD and logged in and the network is connected
When I double-click on the Tails documentation launcher on the desktop
Then the Tor Browser has started
And "Tails - Getting started..." has loaded in the Tor Browser
Scenario: The Tor Browser uses TBB's shared libraries
Given I have started Tails from DVD and logged in and the network is connected
When I start the Tor Browser
......
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