From 5cf77af233ad791de2646887f93dfb7266e6a87a Mon Sep 17 00:00:00 2001 From: Alice Date: Tue, 22 Oct 2019 14:09:26 +0200 Subject: [PATCH] use real templating in help pages --- ccvpn/settings.py | 2 +- ccvpn/views.py | 27 ++++++---- poetry.lock | 26 +++++++++- pyproject.toml | 1 + templates/ccvpn/page.html | 5 ++ templates/pages/advanced-tor.md | 69 ++++++++++++++++++++++++++ templates/pages/faq.en.md | 2 + templates/pages/faq.fr.md | 2 + templates/pages/help.en.md | 2 + templates/pages/help.fr.md | 2 + templates/pages/install-android.en.md | 2 + templates/pages/install-android.fr.md | 2 + templates/pages/install-chromeos.en.md | 2 + templates/pages/install-chromeos.fr.md | 2 + templates/pages/install-gnulinux.en.md | 2 + templates/pages/install-gnulinux.fr.md | 2 + templates/pages/install-osx.en.md | 2 + templates/pages/install-osx.fr.md | 2 + templates/pages/install-windows.en.md | 2 + templates/pages/install-windows.fr.md | 2 + templates/pages/nop2p.en.md | 2 + templates/pages/privacy.en.md | 2 + templates/pages/self-diagnosis.en.md | 2 + templates/pages/self-diagnosis.fr.md | 2 + templates/pages/tos.en.md | 2 + 25 files changed, 155 insertions(+), 13 deletions(-) create mode 100644 templates/pages/advanced-tor.md diff --git a/ccvpn/settings.py b/ccvpn/settings.py index 57447f1..6c1f353 100644 --- a/ccvpn/settings.py +++ b/ccvpn/settings.py @@ -232,7 +232,7 @@ PAYMENTS_BACKENDS = { # 'receiver': '', # PayPal primary address if different # 'currency': 'EUR', # 'header_image': '', - 'api_username': ', + 'api_username': '', 'api_password': '', 'api_sig': '', }, diff --git a/ccvpn/views.py b/ccvpn/views.py index 95eb04b..307ac62 100644 --- a/ccvpn/views.py +++ b/ccvpn/views.py @@ -3,9 +3,9 @@ import re import markdown from markdown.extensions.codehilite import CodeHiliteExtension +from markdown.extensions.toc import TocExtension from django.http import HttpResponseNotFound from django.shortcuts import render -from django.views.decorators.cache import cache_page from django.conf import settings from django.utils.translation import ugettext as _, get_language from django import http @@ -14,17 +14,14 @@ from django.utils.translation import ( LANGUAGE_SESSION_KEY, check_for_language, ) from django.template.loader import TemplateDoesNotExist, get_template +from django.template import Template from constance import config +import frontmatter from downloads.models import Version from .common import get_price_float -MARKDOWN = markdown.Markdown(extensions=[ - 'markdown.extensions.toc', - 'markdown.extensions.meta', - CodeHiliteExtension(noclasses=True), -]) def index(request): @@ -62,7 +59,6 @@ def set_lang(request): return response -@cache_page(5 * 60) def page(request, name): if not re.match('^[a-z0-9_-]{1,50}$', name): return HttpResponseNotFound() @@ -83,9 +79,20 @@ def page(request, name): except TemplateDoesNotExist: continue - page_md = template.render(None, request) - page_html = MARKDOWN.convert(page_md) - title = MARKDOWN.Meta.get('title', [None])[0] + page_source = template.render(None, request) + page = frontmatter.loads(page_source) + page_md = page.content + + title = page.metadata.get('Title', "") + toc_depth = int(page.metadata.get('TocDepth', 6)) + + md = markdown.Markdown(extensions=[ + TocExtension(toc_depth=toc_depth), + 'markdown.extensions.meta', + CodeHiliteExtension(noclasses=True), + ]) + page_html = md.convert(page_md) + ctx = dict(content=page_html, title=title) return render(request, 'ccvpn/page.html', ctx) diff --git a/poetry.lock b/poetry.lock index 6dd3430..118e8ec 100644 --- a/poetry.lock +++ b/poetry.lock @@ -196,6 +196,18 @@ optional = false python-versions = "*" version = "0.10.1" +[[package]] +category = "main" +description = "Parse and manage posts with YAML frontmatter" +name = "python-frontmatter" +optional = false +python-versions = "*" +version = "0.4.5" + +[package.dependencies] +PyYAML = "*" +six = "*" + [[package]] category = "main" description = "World timezone definitions, modern and historical" @@ -204,6 +216,14 @@ optional = false python-versions = "*" version = "2019.1" +[[package]] +category = "main" +description = "YAML parser and emitter for Python" +name = "pyyaml" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +version = "5.1.2" + [[package]] category = "main" description = "Python HTTP for Humans." @@ -219,7 +239,7 @@ idna = ">=2.5,<2.9" urllib3 = ">=1.21.1,<1.25" [[package]] -category = "dev" +category = "main" description = "Python 2 and 3 compatibility utilities" name = "six" optional = false @@ -273,7 +293,7 @@ python-versions = "*" version = "1.11.1" [metadata] -content-hash = "904e2f74a8bbc7c194b4a9d9ee1dd069338f52cde373e44d4c84cb659af043ae" +content-hash = "5a877ca66b221fad6e7837be828b4474efe123d30feb664c6b11bb38edc4ce07" python-versions = "^3.5" [metadata.hashes] @@ -297,7 +317,9 @@ pygal = ["27abab93cbc31e21f3c6bdecc05bda6cd3570cbdbd8297b7caa6904051b50d72", "92 pygments = ["31cba6ffb739f099a85e243eff8cb717089fdd3c7300767d9fc34cb8e1b065f5", "5ad302949b3c98dd73f8d9fcdc7e9cb592f120e32a18e23efd7f3dc51194472b"] pylint = ["5d77031694a5fb97ea95e828c8d10fc770a1df6eb3906067aaed42201a8a6a09", "723e3db49555abaf9bf79dc474c6b9e2935ad82230b10c1138a71ea41ac0fff1"] python-bitcoinlib = ["0fe7de6c083e12479eb12d3764ece83e5c73b1c48e806009ee1a1aa02da098cf", "4c5ab6d6937086b2964a97182ca04d9a7ecfe9295ab9520f58ac13a1f54e9183"] +python-frontmatter = ["13a61749910f2e1968c011103406429abc79c41d52b69adfb07f702ae2df32cc", "cec75b2afd1a06cf5b03cfd9c5173365d3dc14379526389a9742ff35846df771"] pytz = ["303879e36b721603cc54604edcac9d20401bdbe31e1e4fdee5b9f98d5d31dfda", "d747dd3d23d77ef44c6a3526e274af6efeb0a6f1afd5a69ba4d5be4098c8e141"] +pyyaml = ["0113bc0ec2ad727182326b61326afa3d1d8280ae1122493553fd6f4397f33df9", "01adf0b6c6f61bd11af6e10ca52b7d4057dd0be0343eb9283c878cf3af56aee4", "5124373960b0b3f4aa7df1707e63e9f109b5263eca5976c66e08b1c552d4eaf8", "5ca4f10adbddae56d824b2c09668e91219bb178a1eee1faa56af6f99f11bf696", "7907be34ffa3c5a32b60b95f4d95ea25361c951383a894fec31be7252b2b6f34", "7ec9b2a4ed5cad025c2278a1e6a19c011c80a3caaac804fd2d329e9cc2c287c9", "87ae4c829bb25b9fe99cf71fbb2140c448f534e24c998cc60f39ae4f94396a73", "9de9919becc9cc2ff03637872a440195ac4241c80536632fffeb6a1e25a74299", "a5a85b10e450c66b49f98846937e8cfca1db3127a9d5d1e31ca45c3d0bef4c5b", "b0997827b4f6a7c286c01c5f60384d218dca4ed7d9efa945c3e1aa623d5709ae", "b631ef96d3222e62861443cc89d6563ba3eeb816eeb96b2629345ab795e53681", "bf47c0607522fdbca6c9e817a6e81b08491de50f3766a7a0e6a5be7905961b41", "f81025eddd0327c7d4cfe9b62cf33190e1e736cc6e97502b3ec425f574b3e7a8"] requests = ["502a824f31acdacb3a35b6690b5fbf0bc41d63a24a45c4004352b0242707598e", "7bf2a778576d825600030a110f3c0e3e8edc51dfaafe1c146e39a2027784957b"] six = ["3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"] sqlparse = ["40afe6b8d4b1117e7dff5504d7a8ce07d9a1b15aeeade8a2d10f130a834f8177", "7c3dca29c022744e95b547e867cee89f4fce4373f3549ccd8797d8eb52cdb873"] diff --git a/pyproject.toml b/pyproject.toml index 115e4bc..f065d8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ django-constance = {version = "=2.4",extras = ["database"]} lcoreapi = {git = "https://git.packetimpact.net/lvpn/lcoreapi.git"} pygments = "^2.3" psycopg2-binary = "^2.8" +python-frontmatter = "^0.4.5" [tool.poetry.dev-dependencies] pylint = "^2.3" diff --git a/templates/ccvpn/page.html b/templates/ccvpn/page.html index cd2a819..ae9a142 100644 --- a/templates/ccvpn/page.html +++ b/templates/ccvpn/page.html @@ -19,6 +19,11 @@
  • {% trans 'OS X' %}
  • {% trans 'Chrome OS' %}
  • + + +
    {% if title %} diff --git a/templates/pages/advanced-tor.md b/templates/pages/advanced-tor.md new file mode 100644 index 0000000..accd529 --- /dev/null +++ b/templates/pages/advanced-tor.md @@ -0,0 +1,69 @@ +--- +Title: Using the VPN with Tor +TocDepth: 2 +--- + +The main use of a VPN is to provide an encrypted connection with clean, non-interfering gateways, +but it does not provide much anonymity depending on the threat. +While we pledge not to leak or sell your data to any business or government unless required by law, +we still have to know some information for operational purposes that could be taken by force by a motivated attacker or government agency. + +There are a few ways to combine our VPN with Tor for additional anonymity and privacy. +This page will go over the methods and their uses and issues. + +[TOC] + + +## a. Tor through the VPN + +Much better for anonymity, but requires careful use of end-to-end encryption (HTTPS, SSH, ...) + +#### Pros: + +- it will hide your usage of the Tor network to your ISP or local network (and show a regular VPN or TLS connection instead). +- it will be as anonymous as using Tor directly. + +#### Cons: + +- VPN servers can get identified and blocked. +- it uses Tor exit nodes, which are not under our control and can intercept, monitor, and alter the traffic. + +#### Installation: + +1. Install the VPN. +2. Install tor or the Tor Browser Bundle. + + +## b. VPN through Tor + +Harder to keep anonymous but will provide a clean and secure connection even over Tor. + +#### Pros: + +- it will successfully bypass most firewalls and government censorships thanks to Tor (and Tor bridges). +- your connection to the VPN is anonymized. +- you replace untrusted Tor exit nodes with our servers, likely more reliable and safer. + +#### Cons: + +- this anonymity is lessed depending on the payment method used for the VPN. +- the bandwidth will be limited by Tor and its network. +- VPN servers aren't as anonymous as most Tor exit nodes. please don't get us into any trouble. + + +#### Installation: + +1. Install Tor. The exact method will be highly OS/distribution specific. + +2. Set up the VPN to use Tor: + Edit your VPN configuration file to append the following config (or add it in the "additional config" in CCVPNGUI): + + socks-proxy-retry + socks-proxy 127.0.0.1 9050 + + Replace 9050 by 9150 when using the Tor Browser Bundle. + +3. (Re)connect to the VPN to start using it through Tor. + **Do not** use the Tor Browser Bundle or SOCKS proxy directly if you want to go through the VPN too. + + diff --git a/templates/pages/faq.en.md b/templates/pages/faq.en.md index 5194139..7215235 100644 --- a/templates/pages/faq.en.md +++ b/templates/pages/faq.en.md @@ -1,4 +1,6 @@ +--- Title: Frequently Asked Questions +--- [TOC] diff --git a/templates/pages/faq.fr.md b/templates/pages/faq.fr.md index 8d93fc5..8ece75b 100644 --- a/templates/pages/faq.fr.md +++ b/templates/pages/faq.fr.md @@ -1,4 +1,6 @@ +--- Title: Questions fréquemment posées +--- [TOC] diff --git a/templates/pages/help.en.md b/templates/pages/help.en.md index 75f6f69..cbc88f9 100644 --- a/templates/pages/help.en.md +++ b/templates/pages/help.en.md @@ -1,4 +1,6 @@ +--- Title: Guides +--- ## Installation diff --git a/templates/pages/help.fr.md b/templates/pages/help.fr.md index 29291f1..37d844d 100644 --- a/templates/pages/help.fr.md +++ b/templates/pages/help.fr.md @@ -1,4 +1,6 @@ +--- Title: Guides +--- ## Installation diff --git a/templates/pages/install-android.en.md b/templates/pages/install-android.en.md index 0c8136e..d1100ec 100644 --- a/templates/pages/install-android.en.md +++ b/templates/pages/install-android.en.md @@ -1,4 +1,6 @@ +--- Title: Install on Android +--- 1. First, you have to install [Arne Schwabe's OpenVPN for Android][openvpn_android]. It is the most frequently updated and secure OpenVPN client for Android. diff --git a/templates/pages/install-android.fr.md b/templates/pages/install-android.fr.md index 91b2180..0df5ec7 100644 --- a/templates/pages/install-android.fr.md +++ b/templates/pages/install-android.fr.md @@ -1,4 +1,6 @@ +--- Title: Installation sur Android +--- 1. Installez d'abord [OpenVPN pour Android d'Arne Schwabe][openvpn_android]. C'est le client Android le mieux mis à jour et le plus sécurisé. diff --git a/templates/pages/install-chromeos.en.md b/templates/pages/install-chromeos.en.md index c2125ae..377d0bc 100644 --- a/templates/pages/install-chromeos.en.md +++ b/templates/pages/install-chromeos.en.md @@ -1,4 +1,6 @@ +--- Title: Install on Chrome OS +--- 1. Download the .onc file needed in [your account](/account/config). Select Chrome OS as the target OS. diff --git a/templates/pages/install-chromeos.fr.md b/templates/pages/install-chromeos.fr.md index 3666343..de4228c 100644 --- a/templates/pages/install-chromeos.fr.md +++ b/templates/pages/install-chromeos.fr.md @@ -1,4 +1,6 @@ +--- Title: Install on Chrome OS +--- 1. Téléchargez le fichier .onc requis dans [votre compte](/account/config), en choisissant Chrome OS comme OS. diff --git a/templates/pages/install-gnulinux.en.md b/templates/pages/install-gnulinux.en.md index b37bc62..f64f427 100644 --- a/templates/pages/install-gnulinux.en.md +++ b/templates/pages/install-gnulinux.en.md @@ -1,4 +1,6 @@ +--- Title: Install on GNU/Linux +--- With NetworkManager ------------------- diff --git a/templates/pages/install-gnulinux.fr.md b/templates/pages/install-gnulinux.fr.md index e2b987b..a0ac160 100644 --- a/templates/pages/install-gnulinux.fr.md +++ b/templates/pages/install-gnulinux.fr.md @@ -1,4 +1,6 @@ +--- Title: Installation sous GNU/Linux +--- Avec NetworkManager ------------------- diff --git a/templates/pages/install-osx.en.md b/templates/pages/install-osx.en.md index 83329a1..ec84e6c 100644 --- a/templates/pages/install-osx.en.md +++ b/templates/pages/install-osx.en.md @@ -1,4 +1,6 @@ +--- Title: Install on Mac OS X +--- 1. Download the .ovpn file you need in [your account](/account/config). diff --git a/templates/pages/install-osx.fr.md b/templates/pages/install-osx.fr.md index f2f8935..67e1c46 100644 --- a/templates/pages/install-osx.fr.md +++ b/templates/pages/install-osx.fr.md @@ -1,4 +1,6 @@ +--- Title: Installation sous Mac OS X +--- 1. Télécharger la configuration (.ovpn) dont vous avez besoin dans [votre compte](/account/config). diff --git a/templates/pages/install-windows.en.md b/templates/pages/install-windows.en.md index 6b9708f..270f9d6 100644 --- a/templates/pages/install-windows.en.md +++ b/templates/pages/install-windows.en.md @@ -1,4 +1,6 @@ +--- Title: Install on Windows +--- {% load dltags %} With CCVPN GUI (recommended, simple) diff --git a/templates/pages/install-windows.fr.md b/templates/pages/install-windows.fr.md index a2c28df..cb7ff5c 100644 --- a/templates/pages/install-windows.fr.md +++ b/templates/pages/install-windows.fr.md @@ -1,4 +1,6 @@ +--- Title: Installation sous Windows +--- {% load dltags %} Avec CCVPN GUI (recommandé, simple) diff --git a/templates/pages/nop2p.en.md b/templates/pages/nop2p.en.md index 511b4ae..0aa4ed6 100644 --- a/templates/pages/nop2p.en.md +++ b/templates/pages/nop2p.en.md @@ -1,4 +1,6 @@ +--- Title: NO-P2P Servers +--- See also: our [Privacy Policy](/page/privacy). diff --git a/templates/pages/privacy.en.md b/templates/pages/privacy.en.md index f19eb94..16c86ef 100644 --- a/templates/pages/privacy.en.md +++ b/templates/pages/privacy.en.md @@ -1,4 +1,6 @@ +--- Title: Privacy Policy +--- We believe transparency is one of the most important qualities a VPN service can have. This page is meant to inform users about what informations CCrypto stores, diff --git a/templates/pages/self-diagnosis.en.md b/templates/pages/self-diagnosis.en.md index daab17d..0185a8f 100644 --- a/templates/pages/self-diagnosis.en.md +++ b/templates/pages/self-diagnosis.en.md @@ -1,4 +1,6 @@ +--- Title: Self Diagnosis +--- Windows diff --git a/templates/pages/self-diagnosis.fr.md b/templates/pages/self-diagnosis.fr.md index 5a1da30..60ae258 100644 --- a/templates/pages/self-diagnosis.fr.md +++ b/templates/pages/self-diagnosis.fr.md @@ -1,4 +1,6 @@ +--- Title: Auto-Diagnostic +--- Windows diff --git a/templates/pages/tos.en.md b/templates/pages/tos.en.md index f1937a4..aa0968a 100644 --- a/templates/pages/tos.en.md +++ b/templates/pages/tos.en.md @@ -1,4 +1,6 @@ +--- Title: Terms of Service +--- Cognitive Cryptography provides virtual private networking (VPN) to its clients. You (Client) acknowledge that Cognitive Cryptography and/or any of its parent companies or constituents