summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--ChangeLog6
-rw-r--r--example/templates/article/article_entry.html1
-rw-r--r--example/templates/article/article_footer.html0
-rw-r--r--example/templates/article/article_header.html1
-rw-r--r--example/templates/article/article_list_footer.html1
-rw-r--r--example/templates/article/article_list_header.html2
-rw-r--r--example/templates/article/article_separator.html0
-rw-r--r--example/templates/article/footer.html2
-rw-r--r--example/templates/article/header.html8
-rw-r--r--example/templates/article/index_footer.html0
-rw-r--r--example/templates/article/index_header.html0
-rw-r--r--example/templates/article/tag_entry.html1
-rw-r--r--example/templates/article/tag_index_footer.html0
-rw-r--r--example/templates/article/tag_index_header.html0
-rw-r--r--example/templates/article/tag_list_footer.html1
-rw-r--r--example/templates/article/tag_list_header.html1
-rw-r--r--example/templates/article/tag_separator.html1
-rw-r--r--setup.cfg13
-rw-r--r--src/pyssg/__init__.py4
-rw-r--r--src/pyssg/__main__.py4
-rw-r--r--src/pyssg/file_discovery.py5
-rw-r--r--src/pyssg/file_structure.py76
-rw-r--r--src/pyssg/pyssg.py34
24 files changed, 158 insertions, 5 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..d7cd106
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+David Luevano Alvarado <david@luevano.xyz>
+David Luevano Alvarado <lorentzeus@gmail.com>
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e404d77
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,6 @@
+CHANGES
+=======
+
+* Prepare barebones package info
+* Update readme
+* Initial commit
diff --git a/example/templates/article/article_entry.html b/example/templates/article/article_entry.html
new file mode 100644
index 0000000..6e6befd
--- /dev/null
+++ b/example/templates/article/article_entry.html
@@ -0,0 +1 @@
+<li><a href="$$URL">$$DATE $$TITLE</a></li>
diff --git a/example/templates/article/article_footer.html b/example/templates/article/article_footer.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/example/templates/article/article_footer.html
diff --git a/example/templates/article/article_header.html b/example/templates/article/article_header.html
new file mode 100644
index 0000000..d2954d9
--- /dev/null
+++ b/example/templates/article/article_header.html
@@ -0,0 +1 @@
+<h1>$$TITLE</h1> \ No newline at end of file
diff --git a/example/templates/article/article_list_footer.html b/example/templates/article/article_list_footer.html
new file mode 100644
index 0000000..3d3a44c
--- /dev/null
+++ b/example/templates/article/article_list_footer.html
@@ -0,0 +1 @@
+</ul>
diff --git a/example/templates/article/article_list_header.html b/example/templates/article/article_list_header.html
new file mode 100644
index 0000000..7b504ea
--- /dev/null
+++ b/example/templates/article/article_list_header.html
@@ -0,0 +1,2 @@
+<h2>Articles</h2>
+<ul>
diff --git a/example/templates/article/article_separator.html b/example/templates/article/article_separator.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/example/templates/article/article_separator.html
diff --git a/example/templates/article/footer.html b/example/templates/article/footer.html
new file mode 100644
index 0000000..308b1d0
--- /dev/null
+++ b/example/templates/article/footer.html
@@ -0,0 +1,2 @@
+</body>
+</html>
diff --git a/example/templates/article/header.html b/example/templates/article/header.html
new file mode 100644
index 0000000..48adfef
--- /dev/null
+++ b/example/templates/article/header.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html lang=$$LANG>
+<head>
+<meta charset="utf-8">
+<title>$$TITLE</title>
+$$EXTRAHEAD
+</head>
+<body>
diff --git a/example/templates/article/index_footer.html b/example/templates/article/index_footer.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/example/templates/article/index_footer.html
diff --git a/example/templates/article/index_header.html b/example/templates/article/index_header.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/example/templates/article/index_header.html
diff --git a/example/templates/article/tag_entry.html b/example/templates/article/tag_entry.html
new file mode 100644
index 0000000..3a7aaad
--- /dev/null
+++ b/example/templates/article/tag_entry.html
@@ -0,0 +1 @@
+<a href="$$URL">$$NAME</a> \ No newline at end of file
diff --git a/example/templates/article/tag_index_footer.html b/example/templates/article/tag_index_footer.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/example/templates/article/tag_index_footer.html
diff --git a/example/templates/article/tag_index_header.html b/example/templates/article/tag_index_header.html
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/example/templates/article/tag_index_header.html
diff --git a/example/templates/article/tag_list_footer.html b/example/templates/article/tag_list_footer.html
new file mode 100644
index 0000000..8ce77e5
--- /dev/null
+++ b/example/templates/article/tag_list_footer.html
@@ -0,0 +1 @@
+</p>
diff --git a/example/templates/article/tag_list_header.html b/example/templates/article/tag_list_header.html
new file mode 100644
index 0000000..7a57395
--- /dev/null
+++ b/example/templates/article/tag_list_header.html
@@ -0,0 +1 @@
+<p>Tags: \ No newline at end of file
diff --git a/example/templates/article/tag_separator.html b/example/templates/article/tag_separator.html
new file mode 100644
index 0000000..c3a6e48
--- /dev/null
+++ b/example/templates/article/tag_separator.html
@@ -0,0 +1 @@
+, \ No newline at end of file
diff --git a/setup.cfg b/setup.cfg
index 38d0126..8bebc17 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,13 +1,13 @@
[metadata]
name = pyssg
author = David Luevano Alvarado
-author-email = david@luevano.xyz
+author_email = david@luevano.xyz
maintainer = David Luevano Alvarado
-maintainer-email = david@luevano.xyz
+maintainer_email = david@luevano.xyz
summary = A Static Site Generator using markdown files
-description-file = README.md
+description_file = README.md
license = GPLv3
-home-page = https://github.com/luevano/pyssg
+home_page = https://github.com/luevano/pyssg
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
@@ -20,7 +20,6 @@ keywords =
site
generator
markdown
- minimalist
[files]
packages =
@@ -29,6 +28,10 @@ packages =
[bdist_wheel]
universal = 0
+[entry_points]
+console_scripts =
+ pyssg = pyssg:main
+
[options]
package_dir =
= src
diff --git a/src/pyssg/__init__.py b/src/pyssg/__init__.py
index e69de29..074ae72 100644
--- a/src/pyssg/__init__.py
+++ b/src/pyssg/__init__.py
@@ -0,0 +1,4 @@
+from .pyssg import main
+
+
+__all__ = ['main']
diff --git a/src/pyssg/__main__.py b/src/pyssg/__main__.py
new file mode 100644
index 0000000..01dbe3c
--- /dev/null
+++ b/src/pyssg/__main__.py
@@ -0,0 +1,4 @@
+from .pyssg import main
+
+
+main()
diff --git a/src/pyssg/file_discovery.py b/src/pyssg/file_discovery.py
new file mode 100644
index 0000000..9b3a57d
--- /dev/null
+++ b/src/pyssg/file_discovery.py
@@ -0,0 +1,5 @@
+import os
+
+
+def get_md_files(directory: str) -> list:
+ return os.listdir(directory)
diff --git a/src/pyssg/file_structure.py b/src/pyssg/file_structure.py
new file mode 100644
index 0000000..f349fed
--- /dev/null
+++ b/src/pyssg/file_structure.py
@@ -0,0 +1,76 @@
+import os
+
+
+def create_structure(directory: str):
+ # get initial working directory
+ iwd = os.getcwd()
+
+ # create main dir
+ os.mkdir(directory)
+ os.chdir(directory)
+
+ # create templates dir
+ os.mkdir('templates')
+ os.chdir('templates')
+
+ # create article (blog) barebones template
+ os.mkdir('article')
+ with open('article/header.html', 'w+') as f:
+ f.write('<!DOCTYPE html>\n')
+ f.write('<html lang=$$LANG>\n')
+ f.write('<head>\n')
+ f.write('<meta charset="utf-8">\n')
+ f.write('<title>$$TITLE</title>\n')
+ f.write('$$EXTRAHEAD\n')
+ f.write('</head>\n')
+ f.write('<body>\n')
+
+ with open('article/footer.html', 'w+') as f:
+ f.write('</body>\n')
+ f.write('</html>\n')
+
+ with open('article/index_header.html', 'w+') as f:
+ f.write('')
+
+ with open('article/tag_list_header.html', 'w+') as f:
+ f.write('<p>Tags:')
+
+ with open('article/tag_entry.html', 'w+') as f:
+ f.write('<a href="$$URL">$$NAME</a>')
+
+ with open('article/tag_separator.html', 'w+') as f:
+ f.write(', ')
+
+ with open('article/tag_list_footer.html', 'w+') as f:
+ f.write('</p>\n')
+
+ with open('article/article_list_header.html', 'w+') as f:
+ f.write('<h2>Articles</h2>\n')
+ f.write('<ul>\n')
+
+ with open('article/article_entry.html', 'w+') as f:
+ f.write('<li><a href="$$URL">$$DATE $$TITLE</a></li>\n')
+
+ with open('article/article_separator.html', 'w+') as f:
+ f.write('')
+
+ with open('article/article_list_footer.html', 'w+') as f:
+ f.write('</ul>\n')
+
+ with open('article/index_footer.html', 'w+') as f:
+ f.write('')
+
+ with open('article/tag_index_header.html', 'w+') as f:
+ f.write('')
+
+ with open('article/tag_index_footer.html', 'w+') as f:
+ f.write('')
+
+ with open('article/article_header.html', 'w+') as f:
+ f.write('<h1>$$TITLE</h1>')
+
+ with open('article/article_footer.html', 'w+') as f:
+ f.write('')
+
+ # return to initial working directory
+ os.chdir(iwd)
diff --git a/src/pyssg/pyssg.py b/src/pyssg/pyssg.py
new file mode 100644
index 0000000..6d0df3a
--- /dev/null
+++ b/src/pyssg/pyssg.py
@@ -0,0 +1,34 @@
+import os
+from argparse import ArgumentParser, Namespace
+
+from .file_discovery import get_md_files
+from .file_structure import create_structure
+
+
+def get_options() -> Namespace:
+ parser = ArgumentParser(prog='pyssg',
+ description='''Static Site Generator that reads
+ Markdown files and creates HTML files.''')
+ parser.add_argument('-d', '--directory',
+ default='.',
+ type=str,
+ help='''root directory for all site files,
+ defaults to "." (cwd), uses relative or absolute
+ resolution''')
+ parser.add_argument('-i', '--init',
+ action='store_true',
+ help='''initialize the directory structure where -d
+ specifies''')
+
+ return parser.parse_args()
+
+
+def main():
+ opts = vars(get_options())
+ directory = opts['directory']
+
+ if opts['init']:
+ create_structure(directory)
+
+ os.chdir(directory)
+ root_dir = os.getcwd()