aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2020-04-22 08:20:06 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2020-04-22 08:20:06 +0200
commit24ef10da650d091e67bd82ec3f9b329bcee1a15e (patch)
tree0949631ce27a2f494c1d34b6a086c8afb5030c9e
parenta7217345e1cf9fa878e271fcc199f9a18eb9637f (diff)
Update package
-rw-r--r--README.md44
-rw-r--r--bcst/args.py6
-rwxr-xr-xbcst/bcst17
-rw-r--r--bcst/theme.py16
-rw-r--r--setup.py2
5 files changed, 45 insertions, 40 deletions
diff --git a/README.md b/README.md
index 9073e7f..f920a88 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,18 @@
-Beautiful Custom Start Page
-===
-BCST allow you to create a beautiful start page very quickly. To install the dependencies, simply run:
+# Beautiful Custom Start Page
- > pip install jinja2
+### Basic usage
+**bcst** allow you to create a beautiful start page very quickly. To install **bcst** run
+`pip install bcst`. Then choose a theme (screenshots are availaible on the package repository):
+> bcst -l
+>
+Next step, extract the theme resources:
+> bcst -e \<your-theme>
-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:
+This, will create a `resources.json` in the current directory. Now, you can customize it to your needs. Then, generate your start page:
+> bcst resources.json \<start-page-destination>
+
+VoilĂ !
+
+### Submit your own theme
+TODO
-> ./src/bcst.py \<resource-file-path> \<start-page-destination>
diff --git a/bcst/args.py b/bcst/args.py
index 6ae54bf..993c9ed 100644
--- a/bcst/args.py
+++ b/bcst/args.py
@@ -3,7 +3,9 @@
import argparse
args_parser = argparse.ArgumentParser()
-args_parser.add_argument("resource", help="A JSON resource file.")
-args_parser.add_argument("destination", help="Start page folder name.")
+args_parser.add_argument("resource", nargs="?", help="A JSON resource file.")
+args_parser.add_argument("destination", nargs="?",help="Start page folder name.")
+args_parser.add_argument("-l","--list", dest="list",action="store_true", help="List available themes.")
+args_parser.add_argument("-e","--extract", metavar="theme",dest="extract", help="Extract theme resource.")
args = args_parser.parse_args()
diff --git a/bcst/bcst b/bcst/bcst
index ebef0d0..a38bf5c 100755
--- a/bcst/bcst
+++ b/bcst/bcst
@@ -2,8 +2,17 @@
from bcst.args import args
from bcst.resource import Resource
-from bcst.theme import Theme
+from bcst.theme import *
-res=Resource(args.resource)
-t=Theme("default",res.json)
-t.deploy(args.destination)
+if args.list:
+ for theme in list_themes():
+ print("- "+theme)
+ exit(0)
+elif args.extract:
+ t=Theme("default")
+ t.extract("resources.json")
+ exit(0)
+elif args.resource and args.destination:
+ t=Theme("default")
+ t.update_resource(args.resource)
+ t.deploy(args.destination)
diff --git a/bcst/theme.py b/bcst/theme.py
index 58e7902..9bdd956 100644
--- a/bcst/theme.py
+++ b/bcst/theme.py
@@ -26,11 +26,10 @@ def get_theme_path(name):
class Theme:
- def __init__(self, name, resource_data):
+ def __init__(self, name):
self.theme_path=get_theme_path(name)
- res=Resource(self.theme_path+"/resources.json")
- self.data=res.json
- self.data.update(resource_data)
+ self.res_path=self.theme_path+"/resources.json"
+ self.data=Resource(self.res_path).json
# Read theme
try:
with open(self.theme_path+"/index.html",'r') as f:
@@ -39,6 +38,15 @@ class Theme:
print("Unable to found "+resource)
exit(1)
+ def update_resource(self,resource_path):
+ r=Resource(resource_path)
+ self.data.update(r.json)
+
+
+ def extract(self, dest):
+ with open(dest, "w") as resFile:
+ resFile.write(self.data.data)
+
def deploy(self, dest_path):
copytree(self.theme_path, dest_path, dirs_exist_ok=True,ignore=ignore_patterns("*.json","index.html"))
diff --git a/setup.py b/setup.py
index 956a27d..e606f54 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as readme:
setuptools.setup(
name="bcst",
- version="0.0.3",
+ version="0.0.4",
scripts=["bcst/bcst"],
author="Loic Guegan",
author_email="manzerbredes@mailbox.org",