Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Denis Salem
VenC
Commits
dbbf825d
Commit
dbbf825d
authored
Jul 13, 2019
by
Denis Salem
Browse files
Rework on chapters engine.
parent
84cfa7c6
Changes
12
Hide whitespace changes
Inline
Side-by-side
VenC-site/blog_configuration.yaml
View file @
dbbf825d
...
...
@@ -15,6 +15,7 @@ code_highlight_css_override: true
markup_language
:
'
Markdown'
path
:
category_directory_name
:
'
{category}'
chapter_directory_name
:
'
{chapter_name}'
dates_directory_name
:
'
%m-%Y'
entry_file_name
:
index.html
ftp
:
Chemin absolu de votre blog sur l'hôte FTP.
...
...
@@ -23,7 +24,8 @@ path:
atom_file_name
:
atom_feed.xml
dates_sub_folders
:
"
"
categories_sub_folders
:
"
"
entries_sub_folders
:
"
{entry_title}"
entries_sub_folders
:
"
"
chapters_sub_folders
:
"
chapters/{chapter_name}"
reverse_thread_order
:
false
feed_lenght
:
5
text_editor
:
gvim
...
...
@@ -32,10 +34,12 @@ disable_atom_feed: true
disable_main_thread
:
true
disable_threads
:
"
"
disable_archives
:
true
disable_chapters
:
false
disable_categories
:
true
disable_single_entries
:
fals
e
disable_single_entries
:
tru
e
banner
:
'
https://download.tuxfamily.org/dsalem/img/2017_-_Denis_Salem_-_CC_By_SA_-_VenC-logo.svg'
path_encoding
:
'
windows-1252'
server_port
:
8888
sort_by
:
'
chapter'
enable_jsonld
:
True
enable_jsonp
:
False
VenC-site/extra/venc_source_Yaml.css
View file @
dbbf825d
...
...
@@ -66,11 +66,4 @@
.venc_source_Yaml
.vg
{
color
:
#19177C
}
/* Name.Variable.Global */
.venc_source_Yaml
.vi
{
color
:
#19177C
}
/* Name.Variable.Instance */
.venc_source_Yaml
.vm
{
color
:
#19177C
}
/* Name.Variable.Magic */
.venc_source_Yaml
.il
{
color
:
#666666
}
/* Literal.Number.Integer.Long */
.venc_source_Yamltable
{
width
:
100%
;
display
:
block
;}
.venc_source_Yamltable
tr
{
width
:
100%
;
display
:
block
;}
.venc_source_Yamltable
tbody
{
width
:
100%
;
display
:
block
;}
.venc_source_Yamltable
.linenos
{
width
:
4%
;
display
:
inline-block
;
vertical-align
:
top
;}
.venc_source_Yamltable
.code
{
width
:
95%
;
display
:
inline-block
;
vertical-align
:
top
;}
.venc_source_Yamltable
td
pre
{
vertical-align
:
top
;
overflow
:
hidden
;
overflow-x
:
scroll
;}
.venc_source_Yaml
pre
{
overflow
:
hidden
;
overflow-x
:
scroll
;}
\ No newline at end of file
.venc_source_Yaml
.il
{
color
:
#666666
}
/* Literal.Number.Integer.Long */
\ No newline at end of file
src/venc-blog-migration
View file @
dbbf825d
...
...
@@ -115,6 +115,7 @@ new_keys = {
"disable_main_thread"
:
False
,
"disable_archives"
:
False
,
"disable_categories"
:
False
,
"disable_chapters"
:
True
,
"disable_single_entries"
:
False
,
"path_encoding"
:
"utf-8"
,
"code_highlight_css_override"
:
False
,
...
...
@@ -130,6 +131,8 @@ new_keys = {
new_path_keys
=
{
"atom_file_name"
:
"atom_feed.xml"
,
"entries_sub_folders"
:
""
,
"chapters_sub_folders"
:
"chapters"
,
"chapter_directory_name"
:
"{chapter_name}"
,
"categories_sub_folders"
:
""
,
"dates_sub_folders"
:
""
}
...
...
src/venc2/commands/export.py
View file @
dbbf825d
...
...
@@ -189,6 +189,11 @@ def export_blog(argv=list()):
thread
=
EntriesThread
(
messages
.
export_single_entries
,
datastore
,
theme
,
patterns_map
)
thread
.
do
()
if
not
datastore
.
blog_configuration
[
"disable_chapters"
]:
from
venc2.threads.chapters
import
ChaptersThread
thread
=
ChaptersThread
(
messages
.
export_chapters
,
datastore
,
theme
,
patterns_map
)
thread
.
do
()
# Copy assets and extra files
notify
(
'└─ '
+
messages
.
copy_assets_and_extra_files
)
code_highlight
.
export_style_sheets
()
...
...
src/venc2/commands/new.py
View file @
dbbf825d
...
...
@@ -125,6 +125,7 @@ def new_blog(argv):
"disable_threads"
:
""
,
"disable_archives"
:
False
,
"disable_categories"
:
False
,
"disable_chapters"
:
True
,
"disable_single_entries"
:
False
,
"disable_main_thread"
:
False
,
"disable_rss_feed"
:
False
,
...
...
@@ -146,8 +147,10 @@ def new_blog(argv):
"entries_sub_folders"
:
""
,
"categories_sub_folders"
:
""
,
"dates_sub_folders"
:
""
,
"chapters_sub_folders"
:
"chapters"
,
"index_file_name"
:
"index{page_number}.html"
,
"category_directory_name"
:
"{category}"
,
"chapter_directory_name"
:
"{chapter_name}"
,
"dates_directory_name"
:
"%Y-%m"
,
"entry_file_name"
:
"entry{entry_id}.html"
,
"rss_file_name"
:
"rss.xml"
,
...
...
src/venc2/datastore/__init__.py
View file @
dbbf825d
...
...
@@ -22,7 +22,7 @@ import os
import
datetime
import
json
import
urllib
.
parse
from
urllib.parse
import
quote
as
urllib
_
parse
_quote
from
venc2.datastore.configuration
import
get_blog_configuration
from
venc2.datastore.entry
import
yield_entries_content
...
...
@@ -57,6 +57,7 @@ class DataStore:
self
.
enable_jsonld
=
self
.
blog_configuration
[
"enable_jsonld"
]
self
.
enable_jsonp
=
self
.
blog_configuration
[
"enable_jsonp"
]
self
.
blog_url
=
self
.
blog_configuration
[
"blog_url"
]
self
.
path_encoding
=
self
.
blog_configuration
[
"path_encoding"
]
self
.
disable_threads
=
[
thread_name
.
strip
()
for
thread_name
in
self
.
blog_configuration
[
"disable_threads"
].
split
(
','
)]
self
.
entries
=
list
()
self
.
entries_per_dates
=
list
()
...
...
@@ -95,7 +96,7 @@ class DataStore:
self
.
blog_configuration
[
"path"
],
jsonld_callback
,
self
.
blog_configuration
[
"path"
][
"dates_directory_name"
],
self
.
blog_configuration
[
"
path_encoding
"
]
self
.
path_encoding
))
except
MalformedPatterns
as
e
:
...
...
@@ -123,17 +124,18 @@ class DataStore:
# Update entriesPerCategories
try
:
sub_folders
=
urllib
.
parse
.
quote
(
self
.
blog_configuration
[
"path"
][
"categories_sub_folders"
]
+
'/'
,
encoding
=
self
.
blog_configuration
[
"
path_encoding
"
]
)
sub_folders
=
urllib
_
parse
_
quote
(
self
.
blog_configuration
[
"path"
][
"categories_sub_folders"
]
+
'/'
,
encoding
=
self
.
path_encoding
)
except
UnicodeEncodeError
as
e
:
sub_folders
=
self
.
blog_configuration
[
"path"
][
"categories_sub_folders"
]
+
'/'
notify
(
"
\"
{0}
\"
: "
.
format
(
sub_folders
)
+
str
(
e
),
color
=
"YELLOW"
)
sub_folders
=
sub_folders
if
sub_folders
!=
'/'
else
''
build_categories_tree
(
entry_index
,
current_entry
.
raw_categories
,
self
.
entries_per_categories
,
self
.
categories_leaves
,
self
.
max_category_weight
,
self
.
set_max_category_weight
,
encoding
=
self
.
blog_configuration
[
"
path_encoding
"
]
,
sub_folders
=
sub_folders
)
build_categories_tree
(
entry_index
,
current_entry
.
raw_categories
,
self
.
entries_per_categories
,
self
.
categories_leaves
,
self
.
max_category_weight
,
self
.
set_max_category_weight
,
encoding
=
self
.
path_encoding
,
sub_folders
=
sub_folders
)
self
.
update_chapters
(
current_entry
)
# build chapters index
chapters_sub_folders
=
self
.
blog_configuration
[
"path"
][
"chapters_sub_folders"
]
for
chapter
in
sorted
(
self
.
raw_chapters
.
keys
()):
top
=
self
.
chapters_index
index
=
''
...
...
@@ -154,20 +156,22 @@ class DataStore:
except
StopIteration
:
try
:
top
.
append
(
Chapter
(
index
,
self
.
raw_chapters
[
index
]
[
1
],
self
.
raw_chapters
[
index
][
2
]
)
Chapter
(
index
,
self
.
raw_chapters
[
index
])
)
except
KeyError
:
top
.
append
(
Chapter
(
index
,
''
,
''
)
)
top
=
top
[
-
1
].
sub_chapters
# Setup BlogArchives Data
self
.
blog_dates
=
list
()
""" Should use encoding for path value as well """
for
node
in
self
.
entries_per_dates
:
try
:
sub_folders
=
urllib
.
parse
.
quote
(
self
.
blog_configuration
[
"path"
][
"dates_sub_folders"
]
+
'/'
,
encoding
=
self
.
blog_configuration
[
"
path_encoding
"
]
)
sub_folders
=
urllib
_
parse
_
quote
(
self
.
blog_configuration
[
"path"
][
"dates_sub_folders"
]
+
'/'
,
encoding
=
self
.
path_encoding
)
except
UnicodeEncodeError
as
e
:
sub_folders
=
self
.
blog_configuration
[
"path"
][
"dates_sub_folders"
]
+
'/'
...
...
@@ -388,19 +392,32 @@ class DataStore:
lo
,
io
,
ic
,
lc
=
argv
if
top
==
[]:
return
''
path_encoding
=
self
.
path_encoding
output
=
lo
.
format
(
**
{
"level"
:
level
})
for
sub_chapters
in
top
:
chapter_sub_folder
=
self
.
blog_configuration
[
"path"
][
"chapters_sub_folders"
]
chapter_folder_name
=
self
.
blog_configuration
[
"path"
][
"chapter_directory_name"
]
for
sub_chapter
in
top
:
try
:
path
=
(
chapter_sub_folder
+
'/'
+
chapter_folder_name
).
format
(
**
{
"chapter_name"
:
sub_chapter
.
entry
.
title
,
"chapter_index"
:
sub_chapter
.
index
})
except
KeyError
as
e
:
print
(
"Unknown variable"
,
e
)
output
+=
io
.
format
(
**
{
"index"
:
sub_chapter
s
.
index
,
"title"
:
sub_chapter
s
.
title
,
"path"
:
sub_chapters
.
path
,
"index"
:
sub_chapter
.
index
,
"title"
:
sub_chapter
.
entry
.
title
,
"path"
:
".:GetRelativeOrigin:."
+
urllib_parse_quote
(
path
,
encoding
=
path_encoding
)
,
"level"
:
level
})
output
+=
self
.
build_html_chapters
(
argv
,
sub_chapter
s
.
sub_chapters
,
level
+
1
)
output
+=
self
.
build_html_chapters
(
argv
,
sub_chapter
.
sub_chapters
,
level
+
1
)
output
+=
ic
output
+=
lc
return
output
def
update_chapters
(
self
,
entry
):
...
...
@@ -424,7 +441,7 @@ class DataStore:
chapter
))
else
:
self
.
raw_chapters
[
chapter
]
=
(
entry
.
id
,
entry
.
title
,
entry
.
url
)
self
.
raw_chapters
[
chapter
]
=
entry
def
sort
(
self
,
entry
):
try
:
...
...
src/venc2/datastore/configuration.py
View file @
dbbf825d
...
...
@@ -50,6 +50,7 @@ def get_blog_configuration():
"disable_main_thread"
,
"disable_archives"
,
"disable_categories"
,
"disable_chapters"
,
"disable_single_entries"
,
"path_encoding"
,
"code_highlight_css_override"
,
...
...
@@ -70,6 +71,7 @@ def get_blog_configuration():
mandatory_fields
=
[
"index_file_name"
,
"category_directory_name"
,
"chapter_directory_name"
,
"dates_directory_name"
,
"entry_file_name"
,
"rss_file_name"
,
...
...
@@ -77,7 +79,8 @@ def get_blog_configuration():
"ftp"
,
"entries_sub_folders"
,
"categories_sub_folders"
,
"dates_sub_folders"
"dates_sub_folders"
,
"chapters_sub_folders"
,
]
for
field
in
mandatory_fields
:
...
...
src/venc2/datastore/metadata.py
View file @
dbbf825d
...
...
@@ -23,12 +23,10 @@ import urllib.parse
from
venc2.prompt
import
notify
class
Chapter
:
def
__init__
(
self
,
index
,
title
,
path
):
def
__init__
(
self
,
index
,
entry
):
self
.
sub_chapters
=
[]
self
.
index
=
index
self
.
title
=
title
self
.
path
=
path
self
.
entry
=
entry
class
MetadataNode
:
def
__init__
(
self
,
value
,
entry_index
):
...
...
src/venc2/l10n/en.py
View file @
dbbf825d
...
...
@@ -53,6 +53,7 @@ class Messages:
export_main_thread
=
"Exporting local main entries thread."
export_main_thread_rss
=
"Exporting local main RSS feed entries."
export_categories
=
"Exporting local entries grouped by categories..."
export_chapters
=
"Exporting local chapters..."
export_categoriesRss
=
"Exporting local entries RSS feed thread from category '{0}'."
missing_mandatory_field_in_entry
=
"Field '{0}' in entry number {1} is missing."
for_unknown_value
=
"For: Value {0} isn't defined."
...
...
src/venc2/l10n/fr.py
View file @
dbbf825d
...
...
@@ -52,6 +52,7 @@ class Messages:
export_main_thread
=
"Exportation locale du fil de publications principal."
export_main_rhread_rss
=
"Exportation locale du flux RSS du fil de publications principal."
export_categories
=
"Exportation locale des publications groupées par categories..."
export_chapters
=
"Exportation locale des chapitres..."
export_categories_rss
=
"Exportation locale du flux RSS du fil de publications de la categorie '{0}'."
missing_mandatory_field_in_entry
=
"Le champ '{0}' dans l'entrée numéro {1} est manquant."
recursive_for_unknown_value
=
"RecursiveFor: La valeur {0} n'existe pas."
...
...
@@ -108,4 +109,3 @@ class Messages:
nothing_to_serv
=
"Rien à faire. Essayez venc -xb d'abord."
theme_has_no_description
=
"Ce thème n'a pas de description."
undefined_variable
=
"{0} n'est pas défini dans
\"
{1}
\"
."
src/venc2/threads/categories.py
View file @
dbbf825d
...
...
@@ -18,7 +18,6 @@
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import
os
import
urllib.parse
from
venc2.prompt
import
notify
from
venc2.threads
import
Thread
...
...
src/venc2/threads/entries.py
View file @
dbbf825d
...
...
@@ -30,11 +30,7 @@ class EntriesThread(Thread):
def
__init__
(
self
,
prompt
,
datastore
,
theme
,
patterns_map
):
super
().
__init__
(
prompt
,
datastore
,
theme
,
patterns_map
)
self
.
entries_per_page
=
1
#override value
self
.
organize_entries
([
entry
for
entry
in
datastore
.
get_entries
(
False
)
])
self
.
organize_entries
(
datastore
.
entries
)
self
.
filename
=
self
.
datastore
.
blog_configuration
[
"path"
][
"entry_file_name"
]
self
.
sub_folders
=
self
.
datastore
.
blog_configuration
[
"path"
][
"entries_sub_folders"
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment