Compare commits
4 Commits
40db35cf7f
...
master
Author | SHA1 | Date | |
---|---|---|---|
9836cd5cd7 | |||
808bf6f8d3 | |||
9948cd85ae | |||
a55ce5a390 |
@@ -4,6 +4,11 @@ It is written in python and everytime a new post is made, that post is added to
|
||||
Glogger uses this file to build a frontend with a customisable format.
|
||||
=> gemini://deadvey.com/gemlog Example of Glogger in action
|
||||
|
||||
# Command line options
|
||||
```--help``` Shows help text
|
||||
```--rebuild``` Rewrite every static page in the site
|
||||
```--config={configuration file}``` Specifiy the file path of the configuration file, default: config.py
|
||||
|
||||
# Setup
|
||||
## Prerequisits:
|
||||
* python3.12 or later (might work on other versions)
|
||||
@@ -28,6 +33,8 @@ python3 glogger.py
|
||||
```
|
||||
|
||||
# TO DO
|
||||
* Activity Pub support
|
||||
* Newsletter support
|
||||
* Add ATOM support
|
||||
* Properly comment everything
|
||||
* Better logging to help debug
|
||||
|
@@ -9,19 +9,23 @@ def create_rss():
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>{config.site_name}</title>
|
||||
<link>{config.site_url}</title>
|
||||
<link>{config.site_url}</link>
|
||||
<description>{config.site_description}</description>
|
||||
<pubDate>{datetime.now().strftime("%a, %d %b %Y %H:%M:%S %z")}</pubDate>
|
||||
<lastBuildDate>{datetime.now().strftime("%a, %d %b %Y %H:%M:%S %z")}</lastBuildDate>
|
||||
'''
|
||||
for current_post_index in range(len(posts.posts)):
|
||||
for current_post_index in range(len(posts.posts)-1,-1,-1):
|
||||
file_content += f'''
|
||||
<item>
|
||||
<title>{posts.posts[current_post_index]["title"]}</title>
|
||||
<link>{config.site_url}/post/{current_post_index}.{config.file_extension}</link>
|
||||
<description>{posts.posts[current_post_index]["content"]}</descriptiont>
|
||||
<pubDate>{posts.posts[current_post_index]["pubdate"]}</pubDate>
|
||||
<editDate>{posts.posts[current_post_index]["editdate"]}</editDate>
|
||||
<description>{posts.posts[current_post_index]["content"]}</description>
|
||||
<pubDate>
|
||||
{datetime.strptime(posts.posts[current_post_index]["pubdate"],"%d%m%YZ%H%M%ST").strftime("%a, %d %b %Y %H:%M:%S %z")}
|
||||
</pubDate>
|
||||
<editDate>
|
||||
{datetime.strptime(posts.posts[current_post_index]["editdate"],"%d%m%YZ%H%M%ST").strftime("%a, %d %b %Y %H:%M:%S %z")}
|
||||
</editDate>
|
||||
</item>'''
|
||||
file_content += '''
|
||||
</channel>
|
||||
|
34
glogger.py
34
glogger.py
@@ -6,11 +6,15 @@ import editpost
|
||||
import rebuild
|
||||
import initialise
|
||||
|
||||
help_text = '''
|
||||
If no argument is passed, glogger will ask for a username;
|
||||
if that user exists, it will as if you want to create a new post, or edit a post (TODO)
|
||||
--help Output this help text
|
||||
--rebuild Rewrite every static page in the site
|
||||
--config={configuration file path} Specify the file path of the configuration
|
||||
'''
|
||||
|
||||
config_file_path = "config.py"
|
||||
if len(sys.argv) > 1:
|
||||
for argument in sys.argv:
|
||||
if argument[:9] == "--config=":
|
||||
config_file_path = argument[9:]
|
||||
|
||||
try:
|
||||
import posts
|
||||
@@ -33,17 +37,27 @@ except:
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
for argument in sys.argv:
|
||||
if argument == "glogger.py":
|
||||
continue
|
||||
if argument == "--help":
|
||||
print('''
|
||||
If no argument is passed, glogger will ask for a username;
|
||||
if that user exists, it will as if you want to create a new post, or edit a post (TODO)
|
||||
--help Output this help text
|
||||
--rebuild Rewrite every static page in the site
|
||||
''')
|
||||
print(help_text)
|
||||
exit()
|
||||
if argument == "--rebuild":
|
||||
rebuild.rebuild()
|
||||
exit()
|
||||
if argument[:9] == "--config=":
|
||||
config_file_path = argument[9:]
|
||||
try:
|
||||
config = SourceFileLoader("config", config_file_path).load_module()
|
||||
if config.autogenerated == True:
|
||||
print("Error: autogenerated = True")
|
||||
exit()
|
||||
except:
|
||||
print(f"{config_file_path} does not exist")
|
||||
exit()
|
||||
else:
|
||||
print(f"Invalid Argument: {argument}")
|
||||
print(help_text)
|
||||
|
||||
username = input("Username: ").lower()
|
||||
|
||||
|
Reference in New Issue
Block a user