aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2020-04-22 07:39:07 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2020-04-22 07:39:07 +0200
commita7217345e1cf9fa878e271fcc199f9a18eb9637f (patch)
tree638d5bcc4e4388ebcb08c9e75ced9d759bb1f3f4
parent5c0cc8e2f4fd632445079abc7af1b65ca0d3a8e0 (diff)
Debug package
-rw-r--r--MANIFEST.in1
-rw-r--r--README.md45
-rwxr-xr-xbcst11
-rw-r--r--bcst/__init__.py (renamed from libs/__init__.py)0
-rw-r--r--bcst/args.py (renamed from libs/args.py)0
-rwxr-xr-xbcst/bcst9
-rw-r--r--bcst/resource.py (renamed from libs/resource.py)2
-rw-r--r--bcst/theme.py48
-rw-r--r--bcst/themes/default/assets/script.js (renamed from themes/default/assets/script.js)0
-rw-r--r--bcst/themes/default/assets/style.css (renamed from themes/default/assets/style.css)0
-rw-r--r--bcst/themes/default/index.html (renamed from themes/default/index.html)0
-rw-r--r--bcst/themes/default/resources.json (renamed from themes/default/resources.json)0
-rw-r--r--libs/theme.py29
-rw-r--r--setup.py6
14 files changed, 86 insertions, 65 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..ebd498f
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1 @@
+recursive-include bcst/themes/ ** \ No newline at end of file
diff --git a/README.md b/README.md
index d6cf9cd..9073e7f 100644
--- a/README.md
+++ b/README.md
@@ -4,28 +4,29 @@ BCST allow you to create a beautiful start page very quickly. To install the dep
> pip install jinja2
-Simple right a simple json resource file:
-
- {
- "title": "Default Theme",
- "bookmarks": {
- "engines": {
- "Qwant": "https://www.qwant.com/",
- "DDG": "https://duckduckgo.com/",
- "Google": "http://google.fr"
- },
- "Reddit": {
- "Home": "https://www.reddit.com/",
- "Unixporn": "https://www.reddit.com/r/Unixporn",
- "Linux": "https://www.reddit.com/me/m/linux"
- },
- "Social": {
- "Discord": "https://discordapp.com/channels/@me",
- "Twitter": "https://twitter.com/",
- "LinuxRocks": "https://linuxrocks.online/web/getting-started"
- }
- }
- }
+Simple write a simple json resource file:
+```
+{
+ "title":"Default Theme",
+ "bookmarks":{
+ "engines":{
+ "Qwant":"https://www.qwant.com/",
+ "DDG":"https://duckduckgo.com/",
+ "Google":"http://google.fr"
+ },
+ "Reddit":{
+ "Home":"https://www.reddit.com/",
+ "Unixporn":"https://www.reddit.com/r/Unixporn",
+ "Linux":"https://www.reddit.com/me/m/linux"
+ },
+ "Social":{
+ "Discord":"https://discordapp.com/channels/@me",
+ "Twitter":"https://twitter.com/",
+ "LinuxRocks":"https://linuxrocks.online/web/getting-started"
+ }
+ }
+}
+```
Then simply run:
> ./src/bcst.py \<resource-file-path> \<start-page-destination>
diff --git a/bcst b/bcst
deleted file mode 100755
index 4e3957e..0000000
--- a/bcst
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env python
-
-from libs.args import args
-from libs.resource import Resource
-from libs.theme import Theme
-
-
-res=Resource(args.resource)
-t=Theme("themes/default",res.json)
-
-t.deploy(args.destination)
diff --git a/libs/__init__.py b/bcst/__init__.py
index e69de29..e69de29 100644
--- a/libs/__init__.py
+++ b/bcst/__init__.py
diff --git a/libs/args.py b/bcst/args.py
index 6ae54bf..6ae54bf 100644
--- a/libs/args.py
+++ b/bcst/args.py
diff --git a/bcst/bcst b/bcst/bcst
new file mode 100755
index 0000000..ebef0d0
--- /dev/null
+++ b/bcst/bcst
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+from bcst.args import args
+from bcst.resource import Resource
+from bcst.theme import Theme
+
+res=Resource(args.resource)
+t=Theme("default",res.json)
+t.deploy(args.destination)
diff --git a/libs/resource.py b/bcst/resource.py
index f521022..342e08a 100644
--- a/libs/resource.py
+++ b/bcst/resource.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
from os import path
-import json, jsonschema
+import json
class Resource:
diff --git a/bcst/theme.py b/bcst/theme.py
new file mode 100644
index 0000000..58e7902
--- /dev/null
+++ b/bcst/theme.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+from bcst.resource import Resource
+from shutil import copytree, ignore_patterns
+from jinja2 import Template
+import os
+from os import path
+
+themes_location=path.join(path.dirname(path.abspath(__file__)),"themes")
+
+
+def list_themes():
+ themes=list()
+ for f in os.listdir(themes_location):
+ if(not(os.path.isfile(os.path.join(themes_location,f)))):
+ themes.append(f)
+ return(themes)
+
+def get_theme_path(name):
+ p=path.join(themes_location,name)
+ if(path.isdir(p)):
+ return(p)
+ else:
+ print("Could not find theme: "+name)
+ exit(1)
+
+class Theme:
+
+ def __init__(self, name, resource_data):
+ self.theme_path=get_theme_path(name)
+ res=Resource(self.theme_path+"/resources.json")
+ self.data=res.json
+ self.data.update(resource_data)
+ # Read theme
+ try:
+ with open(self.theme_path+"/index.html",'r') as f:
+ self.template=Template(f.read())
+ except IOError:
+ print("Unable to found "+resource)
+ exit(1)
+
+
+ def deploy(self, dest_path):
+ copytree(self.theme_path, dest_path, dirs_exist_ok=True,ignore=ignore_patterns("*.json","index.html"))
+ themes_dir=os.path.split(self.theme_path)[0]
+ theme_dir=os.path.split(self.theme_path)[1]
+ with open(dest_path+"/index.html", "w") as index:
+ index.write(self.template.render(self.data))
diff --git a/themes/default/assets/script.js b/bcst/themes/default/assets/script.js
index 4681d9e..4681d9e 100644
--- a/themes/default/assets/script.js
+++ b/bcst/themes/default/assets/script.js
diff --git a/themes/default/assets/style.css b/bcst/themes/default/assets/style.css
index b2676b4..b2676b4 100644
--- a/themes/default/assets/style.css
+++ b/bcst/themes/default/assets/style.css
diff --git a/themes/default/index.html b/bcst/themes/default/index.html
index 82133cb..82133cb 100644
--- a/themes/default/index.html
+++ b/bcst/themes/default/index.html
diff --git a/themes/default/resources.json b/bcst/themes/default/resources.json
index dd2e1ca..dd2e1ca 100644
--- a/themes/default/resources.json
+++ b/bcst/themes/default/resources.json
diff --git a/libs/theme.py b/libs/theme.py
deleted file mode 100644
index 9859451..0000000
--- a/libs/theme.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-
-from resource import Resource
-from shutil import copytree, ignore_patterns
-from jinja2 import Template
-import os
-
-class Theme:
-
- def __init__(self, path, resource_data):
- res=Resource(path+"/resources.json")
- self.theme_path=path.strip('/')
- self.data=res.json
- self.data.update(resource_data)
- # Read theme
- try:
- with open(path+"/index.html",'r') as f:
- self.template=Template(f.read())
- except IOError:
- print("Unable to found "+resource)
- exit(1)
-
-
- def deploy(self, path):
- copytree(self.theme_path, path, dirs_exist_ok=True,ignore=ignore_patterns("*.json","index.html"))
- themes_dir=os.path.split(self.theme_path)[0]
- theme_dir=os.path.split(self.theme_path)[1]
- with open(path+"/index.html", "w") as index:
- index.write(self.template.render(self.data))
diff --git a/setup.py b/setup.py
index a62a99e..956a27d 100644
--- a/setup.py
+++ b/setup.py
@@ -5,14 +5,16 @@ with open("README.md", "r") as readme:
setuptools.setup(
name="bcst",
- version="0.0.1",
- scripts=['bcst'],
+ version="0.0.3",
+ scripts=["bcst/bcst"],
author="Loic Guegan",
author_email="manzerbredes@mailbox.org",
description="A web browser start page generator.",
long_description=long_description,
+ long_description_content_type='text/markdown',
url="https://gitlab.com/manzerbredes/bcst",
install_requires=["jinja2"],
+ include_package_data=True,
packages=setuptools.find_packages(),
classifiers=["License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)"])