Skip to content
GitLab
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
3802bd92
Commit
3802bd92
authored
Jun 24, 2019
by
Denis Salem
Browse files
Done with theme config file
parent
0e351d78
Changes
10
Hide whitespace changes
Inline
Side-by-side
changelog.md
View file @
3802bd92
...
...
@@ -159,7 +159,7 @@
DONE | Fix Shabang issue for compatibility.
DONE | Semantic-web features.
WIP | Client-side search engine.
TODO
| Theme must have it's own yaml configuration.
WIP
| Theme must have it's own yaml configuration.
TODO | Reorganize themes dependencies in setup (adding default templates, scripts, and pages to include).
TODO | Add relevant templates for themes.
TODO | Open with navigator manual.
...
...
src/setup.py
View file @
3802bd92
...
...
@@ -26,14 +26,22 @@ themes = os.listdir(src_themes_path)
extra_files
=
[]
for
theme
in
themes
:
for
sub_folder
in
os
.
listdir
(
src_themes_path
+
theme
+
'/'
):
dst
=
dst_themes_path
+
theme
+
'/'
+
sub_folder
src_files
=
[
src_themes_path
+
theme
+
'/'
+
sub_folder
+
'/'
+
f
for
f
in
os
.
listdir
(
src_themes_path
+
theme
+
'/'
+
sub_folder
)]
for
filename
in
os
.
listdir
(
src_themes_path
+
theme
+
'/'
):
if
os
.
path
.
isdir
(
src_themes_path
+
theme
+
'/'
+
filename
):
dst
=
dst_themes_path
+
theme
+
'/'
+
filename
src_files
=
[
src_themes_path
+
theme
+
'/'
+
filename
+
'/'
+
f
for
f
in
os
.
listdir
(
src_themes_path
+
theme
+
'/'
+
filename
)]
else
:
dst
=
dst_themes_path
+
theme
src_files
=
[
src_themes_path
+
theme
+
'/'
+
filename
]
print
(
dst
,
src_files
)
extra_files
.
append
((
dst
,
src_files
))
extra_files
.
append
((
os
.
path
.
expanduser
(
'~'
)
+
"/.local/share/VenC/embed_providers/"
,[
"share/embed_providers/oembed.json"
]))
setup
(
name
=
'VenC'
,
...
...
src/share/themes/tessellation/config.yaml
0 → 100644
View file @
3802bd92
info
:
description
:
'
theme_description_tessellation'
override
:
columns
:
3
src/venc
View file @
3802bd92
...
...
@@ -47,10 +47,8 @@ command_index = {"-v": [".print", "print_version", 0],
"-rc"
:
[
".remote"
,
"remote_copy"
,
0
],
"-it"
:
[
".install"
,
"install_theme"
,
1
],
"-h"
:
[
".print"
,
"print_help"
,
0
],
"-t"
:
[
".print"
,
"print_themes"
,
0
],
"-s"
:
[
".serv"
,
"serv_blog"
,
0
],
"--serv"
:
[
".serv"
,
"serv_blog"
,
0
],
"--themes"
:
[
".print"
,
"print_themes"
,
0
],
"--help"
:
[
".print"
,
"print_help"
,
0
],
"--install-theme"
:
[
".install"
,
"install_theme"
,
1
],
"--remote-copy"
:
[
".remote"
,
"remote_copy"
,
0
],
...
...
src/venc2/commands/export.py
View file @
3802bd92
...
...
@@ -25,7 +25,6 @@ import time
from
venc2.commands.remote
import
remote_copy
from
venc2.datastore
import
DataStore
from
venc2.datastore.theme
import
themes_descriptor
from
venc2.datastore.theme
import
Theme
from
venc2.prompt
import
notify
from
venc2.helpers
import
rm_tree_error_handler
...
...
@@ -63,19 +62,17 @@ def export_and_remote_copy(argv=list()):
def
init_theme
(
argv
):
theme_folder
=
"theme/"
if
len
(
argv
)
==
1
:
if
not
argv
[
0
]
in
themes_descriptor
.
keys
():
from
venc2.helpers
import
die
die
(
messages
.
theme_doesnt_exists
.
format
(
argv
[
0
]))
else
:
theme_folder
=
os
.
path
.
expanduser
(
"~"
)
+
"/.local/share/VenC/themes/"
+
argv
[
0
]
+
"/"
themes_folder
=
os
.
path
.
expanduser
(
"~"
)
+
"/.local/share/VenC/themes/"
if
len
(
argv
)
==
1
and
os
.
path
.
isdir
(
themes_folder
+
argv
[
0
]):
theme_folder
=
os
.
path
.
expanduser
(
"~"
)
+
"/.local/share/VenC/themes/"
+
argv
[
0
]
+
"/"
for
param
in
themes_descriptor
[
argv
[
0
]].
keys
():
if
param
[
0
]
!=
"_"
:
# marker to detect field names we do not want to replace
datastore
.
blog_configuration
[
param
]
=
themes_descriptor
[
argv
[
0
]][
param
]
if
"config.yaml"
in
os
.
listdir
(
theme_folder
)
and
not
os
.
path
.
isdir
(
themes_folder
+
"/config.yaml"
):
import
yaml
config
=
yaml
.
load
(
open
(
theme_folder
+
"/config.yaml"
,
'r'
).
read
())
if
"override"
in
config
.
keys
()
and
type
(
config
[
"override"
])
==
dict
:
for
param
in
config
[
"override"
].
keys
():
datastore
.
blog_configuration
[
param
]
=
config
[
"override"
][
param
]
try
:
return
Theme
(
theme_folder
),
theme_folder
...
...
src/venc2/commands/install.py
View file @
3802bd92
...
...
@@ -22,13 +22,40 @@ import os
import
shutil
from
venc2.datastore.configuration
import
get_blog_configuration
from
venc2.prompt
import
msg_format
from
venc2.prompt
import
notify
from
venc2.prompt
import
die
from
venc2.l10n
import
messages
def
print_themes
():
import
os
import
yaml
themes_folder
=
os
.
path
.
expanduser
(
'~'
)
+
"/.local/share/VenC/themes/"
for
theme
in
os
.
listdir
(
themes_folder
):
if
"config.yaml"
in
os
.
listdir
(
themes_folder
+
theme
)
and
not
os
.
path
.
isdir
(
themes_folder
+
theme
+
"/config.yaml"
):
config
=
yaml
.
load
(
open
(
themes_folder
+
theme
+
"/config.yaml"
,
'r'
).
read
())
try
:
description
=
getattr
(
messages
,
config
[
"info"
][
"description"
])
except
AttributeError
:
description
=
config
[
"info"
][
"description"
]
except
KeyError
:
description
=
messages
.
theme_has_no_description
except
TypeError
:
description
=
messages
.
theme_has_no_description
else
:
description
=
messages
.
theme_has_no_description
print
(
"- "
+
msg_format
[
"GREEN"
]
+
theme
+
msg_format
[
"END"
]
+
":"
,
description
)
def
install_theme
(
argv
):
if
len
(
argv
)
<
1
:
die
(
messages
.
missing_params
.
format
(
"--install-themes"
))
print_themes
()
return
blog_configuration
=
get_blog_configuration
()
if
blog_configuration
==
None
:
...
...
@@ -45,14 +72,14 @@ def install_theme(argv):
try
:
shutil
.
copytree
(
os
.
path
.
expanduser
(
"~"
)
+
"/.local/share/VenC/themes/"
+
argv
[
0
],
"theme"
)
notify
(
messages
.
theme_installed
)
except
FileNotFoundError
as
e
:
notify
(
messages
.
theme_doesnt_exists
.
format
(
"'"
+
argv
[
0
]
+
"'"
),
color
=
'RED'
)
''' Restore previous states '''
try
:
shutil
.
move
(
new_folder_name
,
"theme"
)
die
(
messages
.
theme_doesnt_exists
.
format
(
"'"
+
argv
[
0
]
+
"'"
))
except
Exception
as
e
:
die
(
str
(
e
))
notify
(
messages
.
theme_installed
)
src/venc2/commands/print.py
View file @
3802bd92
...
...
@@ -17,14 +17,14 @@
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
from
venc2.datastore.theme
import
themes_descriptor
from
venc2.prompt
import
msg_format
from
venc2.l10n
import
messages
;
from
venc2
import
venc_version
def
print_version
(
argv
):
print
(
"VenC"
,
venc_version
)
# Will be removed and replaced by argparse
def
print_help
(
argv
=
None
):
print
(
"-v
\t
--version"
)
print
(
"-nb
\t
--new-blog <
\"
"
+
messages
.
arg_blog_name
.
format
(
"1"
)
+
"
\"
> [
\"
"
+
messages
.
arg_blog_name
.
format
(
"2"
)
+
"
\"
... ]"
)
...
...
@@ -35,9 +35,4 @@ def print_help(argv=None):
print
(
"-xftp
\t
--export-via-ftp"
)
print
(
"-rc
\t
--remote-copy"
)
print
(
"-h
\t
--help"
)
print
(
"-t
\t
--themes"
)
print
(
"-it
\t
--install-themes <"
+
messages
.
theme_name
+
">"
)
def
print_themes
(
argv
=
None
):
for
theme
in
themes_descriptor
.
keys
():
print
(
"- "
+
msg_format
[
"GREEN"
]
+
theme
+
msg_format
[
"END"
]
+
":"
,
themes_descriptor
[
theme
][
"_themeDescription_"
])
src/venc2/datastore/theme.py
View file @
3802bd92
...
...
@@ -22,12 +22,6 @@ from venc2.prompt import die
from
venc2.l10n
import
messages
from
venc2.patterns.processor
import
ProcessedString
themes_descriptor
=
{
"dummy"
:
{
"columns"
:
1
,
"_themeDescription_"
:
messages
.
theme_description_dummy
},
"gentle"
:
{
"columns"
:
1
,
"_themeDescription_"
:
messages
.
theme_description_gentle
},
"tessellation"
:
{
"columns"
:
3
,
"_themeDescription_"
:
messages
.
theme_description_tessellation
},
}
class
Theme
:
def
__init__
(
self
,
theme_folder
):
try
:
...
...
src/venc2/l10n/en.py
View file @
3802bd92
...
...
@@ -107,4 +107,6 @@ class Messages:
generating_jsonld_docs
=
"Generating JSON-LD documents..."
task_done_in_n_seconds
=
"Task done in {0} seconds."
nothing_to_serv
=
"Nothing to do. Try venc -xb before."
theme_has_no_description
=
"This theme has no description."
src/venc2/l10n/fr.py
View file @
3802bd92
...
...
@@ -105,4 +105,5 @@ class Messages:
generating_jsonld_docs
=
"Génération des documents JSON-LD..."
task_done_in_n_seconds
=
"Tache réalisée en {0} seconds."
nothing_to_serv
=
"Rien à faire. Essayez venc -xb d'abord."
theme_has_no_description
=
"Ce thème n'a pas de description."
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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