Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/offline access #134

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[flake8]
ignore =
E125 # continuation line with same indent as next logical line
E251 # unexpected spaces around keyword / parameter equals
E501 # line too long
E203 # whitespace before ':'
E231 # missing whitespace after ','
E265 # block comment should start with '# '
E302 # expected 2 blank lines, found 1
E226 # missing whitespace around arithmetic operator
E225 # missing whitespace around operator
W291 # trailing whitespace
E121 # continuation line under-indented for hanging indent
E122 # continuation line missing indentation or outdented
F841 # local variable 'exc' is assigned to but never used
E722 # do not use bare 'except'
E221 # multiple spaces before operator
E227 # ddd
E202 # whitespace before ')'
E114 # indentation is not a multiple of four (comment)
E111 # indentation is not a multiple of four
E303 # too many blank
E271 # multiple spaces after keyword
W293 # blank line contains whitespace
29 changes: 28 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
material
maintenance/*.txt
html_generiloj/output/
agordoj/auxtoroj-lingvoj.yml
__pycache__
*.pyc
.idea/

html_generiloj/output/ca/
html_generiloj/output/cs/
html_generiloj/output/de/
html_generiloj/output/da/
html_generiloj/output/en/
html_generiloj/output/es/
html_generiloj/output/fr/
html_generiloj/output/he/
html_generiloj/output/hr/
html_generiloj/output/hu/
html_generiloj/output/id/
html_generiloj/output/it/
html_generiloj/output/ko/
html_generiloj/output/ms/
html_generiloj/output/nl/
html_generiloj/output/pl/
html_generiloj/output/pt/
html_generiloj/output/ru/
html_generiloj/output/sk/
html_generiloj/output/sl/
html_generiloj/output/sv/
html_generiloj/output/th/
html_generiloj/output/tr/
html_generiloj/output/uk/
html_generiloj/output/zh/
html_generiloj/output/zh-tw/
16 changes: 16 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
flake8 = "*"

[packages]
mistune = "*"
pyyaml = "*"
jinja2 = "*"
genanki = "*"

[requires]
python_version = "3.7"
153 changes: 153 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ La Esperantaj leciontekstoj en la kurso `enhavo/netradukenda/tekstoj` devas rest
## Pliaj tradukoj?

Ĉu vi volas traduki la kurson al nova lingvo? Belege! Bonvole [plulegu tie](enhavo/tradukenda).

## First time
- pip install pipenv
- pipenv install
1 change: 0 additions & 1 deletion genanki
Submodule genanki deleted from 3895d3
24 changes: 12 additions & 12 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import glob
import re
import os
import sys
import argparse
import html_generiloj
import leo_markdown


def transpose_headlines(markdown, level):
prefix = ''
for i in range(level):
Expand All @@ -28,7 +28,7 @@ def get_markdown_headlines(s):
return headlines


def load(language, gramatiko_transpose_headlines = 2):
def load(language, gramatiko_transpose_headlines=2):

enhavo = {}
enhavo['lingvo'] = language
Expand Down Expand Up @@ -64,17 +64,17 @@ def load(language, gramatiko_transpose_headlines = 2):

path = 'enhavo/tradukenda/' + language + '/enkonduko.md'
enkonduko = open(path).read()
#enkonduko = transpose_headlines(enkonduko, 1)
# enkonduko = transpose_headlines(enkonduko, 1)
enhavo['enkonduko'] = enkonduko

path = 'enhavo/tradukenda/' + language + '/post.md'
enhavo['post'] = open(path).read()
enhavo['post'] = transpose_headlines(enhavo['post'] , 2)
enhavo['post'] = transpose_headlines(enhavo['post'], 2)

lecionoj = []
vortoj = {}

for i in range(1,13):
for i in range(1, 13):
leciono = {
'teksto': None,
'gramatiko': None,
Expand Down Expand Up @@ -138,7 +138,6 @@ def load(language, gramatiko_transpose_headlines = 2):
path = 'enhavo/netradukenda/ekzercoj/kompletigu-la-frazojn/' + i_padded + '.yml'
ekzercoj['Kompletigu la frazojn'] = yaml.load(open(path))


# Covert from dict to list.
leciono['ekzercoj'] = ekzercoj

Expand All @@ -148,6 +147,7 @@ def load(language, gramatiko_transpose_headlines = 2):

return enhavo


ap = argparse.ArgumentParser()

ap.add_argument(
Expand All @@ -172,8 +172,8 @@ def load(language, gramatiko_transpose_headlines = 2):
"--printendaj-partoj",
help="Printendaj partoj",
type=str,
choices=['teksto','vortoj','gramatiko','ekzerco1','ekzerco2','ekzerco3','solvo1', 'solvo2', 'solvo3'],
default=['teksto','vortoj','gramatiko','ekzerco1','ekzerco2','ekzerco3','solvo1', 'solvo2', 'solvo3'],
choices=['teksto', 'vortoj', 'gramatiko', 'ekzerco1', 'ekzerco2', 'ekzerco3', 'solvo1', 'solvo2', 'solvo3'],
default=['teksto', 'vortoj', 'gramatiko', 'ekzerco1', 'ekzerco2', 'ekzerco3', 'solvo1', 'solvo2', 'solvo3'],
nargs='*'
)

Expand All @@ -182,8 +182,8 @@ def load(language, gramatiko_transpose_headlines = 2):
"--printendaj-lecionoj",
help="Printendaj lecionoj",
type=int,
choices=[1,2,3,4,5,6,7,8,9,10,11,12],
default=[1,2,3,4,5,6,7,8,9,10,11,12],
choices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
default=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
nargs='*'
)

Expand All @@ -199,7 +199,7 @@ def load(language, gramatiko_transpose_headlines = 2):
lingvoj = yaml.load(open('agordoj/lingvoj.yml').read())

if args.eligformo == 'html':
#if args.lingvo not in lingvoj.keys():
# if args.lingvo not in lingvoj.keys():
# sys.exit("'" + args.lingvo + "' ne estas havebla lingvokodo.")
enhavo = load(args.lingvo)
enhavo['lingvoj'] = lingvoj
Expand All @@ -210,4 +210,4 @@ def load(language, gramatiko_transpose_headlines = 2):
enhavo = load(args.lingvo, 3)
enhavo['lingvoj'] = lingvoj
enhavo['tekstodirekto'] = lingvoj[args.lingvo].get('tekstodirekto', 'ltr')
leo_markdown.package.kreu_md(enhavo, printendaj = { 'partoj': args.printendaj_partoj, 'lecionoj': args.printendaj_lecionoj } )
leo_markdown.package.kreu_md(enhavo, printendaj = {'partoj': args.printendaj_partoj, 'lecionoj': args.printendaj_lecionoj})
11 changes: 5 additions & 6 deletions html_generiloj/generi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
import os
import shutil
import re
import yaml, jinja2, mistune

import sys
sys.path = ['./genanki'] + sys.path
import jinja2
import mistune
import genanki


def render_page(name, enhavo, vojprefikso, env, output_path):

rendered = env.get_template(name + '.html').render(
enhavo = enhavo,
vojprefikso = vojprefikso,
enhavo=enhavo,
vojprefikso=vojprefikso,
)

return rendered
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions html_generiloj/output/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
-->
<link href="assets/css/main.css" rel="stylesheet">
<link rel="manifest" href="/manifest.json">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
Expand Down
Loading