Skip to content

This just applies black formatting #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ Clone the following repository and run the script to produce a example blog
```
https://github.com/Drakonis/git2blog-example
```

### Using guix

To enter a development environment run the following:

```
guix shell
```
50 changes: 29 additions & 21 deletions git2blog.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
import os,shutil,pygit2,time, sys
import os, shutil, pygit2, time, sys


def buildblog():
repo = pygit2.Repository(os.path.abspath(sys.argv[1])+'/.git')
repo = pygit2.Repository(os.path.abspath(sys.argv[1]) + "/.git")
last = repo[repo.head.target]
text=''
fmodel = open('models/'+'blog'+'.html','r+')
fmain = open('main.html','w+')
if not os.path.exists('posts'):
os.makedirs('posts')
text = ""
fmodel = open("models/" + "blog" + ".html", "r+")
fmain = open("main.html", "w+")
if not os.path.exists("posts"):
os.makedirs("posts")
ftxt = fmodel.read()
for commit in repo.walk(last.id, pygit2.GIT_SORT_TIME):
id=str(commit.id)
fpost = open('posts/'+id+'.html','w+')
author=commit.author.name
message=commit.message
date=time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(commit.commit_time))
string='<h2>'+id+'</h2>\n<h5>'+date+'</h5>\n<p>'+message+'</p>'
id = str(commit.id)
fpost = open("posts/" + id + ".html", "w+")
author = commit.author.name
message = commit.message
date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(commit.commit_time))
string = "<h2>" + id + "</h2>\n<h5>" + date + "</h5>\n<p>" + message + "</p>"
fpost.write(string)
fpost.close()
text=text+string+'\n'
ftxt=ftxt.format(text=text)
text = text + string + "\n"
ftxt = ftxt.format(text=text)
fmain.write(ftxt)
fmain.close()
fmodel.close()


def index():
dirlist=os.listdir('posts')
text=''
fmodel = open('models/'+'index'+'.html','r+')
fpost = open('index'+'.html','w+')
dirlist = os.listdir("posts")
text = ""
fmodel = open("models/" + "index" + ".html", "r+")
fpost = open("index" + ".html", "w+")
ftxt = fmodel.read()
for dirfile in dirlist:
text=text+'<h1><a href="posts/'+dirfile+'">'+dirfile+'</a></h1>\n'
ftxt=ftxt.format(text=text)
text = text + '<h1><a href="posts/' + dirfile + '">' + dirfile + "</a></h1>\n"
ftxt = ftxt.format(text=text)
fpost.write(ftxt)
fpost.close()
fmodel.close()


def main():
buildblog()
index()


if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions manifest.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(specifications->manifest
'("python-pygit2"))