Merge pull request #4 from empathetic-alligator/master
Implemented support for user templates
This commit is contained in:
27
README.md
27
README.md
@ -20,6 +20,31 @@ Included "art" from left to right: kitty, oneup, oneup2, hackerschool, octocat,
|
||||
3. Run the generated `gitfiti.sh` from your home directory (or any non-git tracked dir) and watch it go to work.
|
||||
4. Wait... Seriously, you'll probably need to wait a day or two for the gitfiti to show in your commit graph.
|
||||
|
||||
### User Templates
|
||||
The file format for personal templates is the following:
|
||||
|
||||
1. Each template starts off with a ":" and then a name (eg. ":foo")
|
||||
2. Each line after that is part of a json-recognizable array.
|
||||
3. The array contain values 0-4, 0 being blank and 4 being dark green.
|
||||
4. To add multiple templates, just add another name tag as described in 1.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
:center-blank
|
||||
[[1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1],
|
||||
[1,1,1,0,1,1,1],
|
||||
[1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1],
|
||||
[1,1,1,1,1,1,1]]
|
||||
```
|
||||
|
||||
This would output a 7 x 7 light green square with a single blank center square.
|
||||
|
||||
Once you have a file with templates, enter its name when prompted and the templates will be added to the list of options.
|
||||
|
||||
###Removal:
|
||||
Fortunately if you regret your gitfiti in the morning, removing it is fairly easy: delete the repo you created for your gitfiti (and wait).
|
||||
|
||||
@ -27,7 +52,7 @@ Fortunately if you regret your gitfiti in the morning, removing it is fairly eas
|
||||
####Todo:
|
||||
- ~~Remove 'requests' dependency~~
|
||||
- Web interface
|
||||
- Load "art" from a file
|
||||
- ~~Load "art" from a file~~
|
||||
- Load commit content from a file
|
||||
- ...
|
||||
- Profit?
|
||||
|
29
gitfiti.py
29
gitfiti.py
@ -87,6 +87,30 @@ images={
|
||||
'hireme':hireme
|
||||
}
|
||||
|
||||
def load_images(imgNames):
|
||||
"""loads user images from given file(s)"""
|
||||
for imageName in imgNames:
|
||||
img = open(imageName)
|
||||
loadedImgs = {}
|
||||
imgList = ''
|
||||
imgLine = ' '
|
||||
name = img.readline().replace('\n', '')
|
||||
name = name[1:]
|
||||
|
||||
while True:
|
||||
imgLine = img.readline()
|
||||
if imgLine == '':
|
||||
break
|
||||
imgLine.replace('\n', '')
|
||||
if(imgLine[0] == ':'):
|
||||
loadedImgs[name] = json.loads(imgList)
|
||||
name = imgLine[1:]
|
||||
imgList = ''
|
||||
else:
|
||||
imgList += imgLine
|
||||
loadedImgs[name] = json.loads(imgList)
|
||||
return loadedImgs
|
||||
|
||||
def get_calendar(username):
|
||||
"""retrieves the github commit calendar data for a username"""
|
||||
BASEURL='https://github.com/'
|
||||
@ -165,6 +189,7 @@ def save(output, filename):
|
||||
f.close()
|
||||
|
||||
def main():
|
||||
global images
|
||||
print '''
|
||||
_ __ _____ __ _
|
||||
____ _(_) /_/ __(_) /_(_)
|
||||
@ -186,6 +211,10 @@ def main():
|
||||
if offset == None: offset = 0
|
||||
else: offset = int(offset)
|
||||
|
||||
print 'enter file(s) to load images from (blank if not applicable)'
|
||||
imgNames = raw_input(">").split(' ')
|
||||
images = dict(images, **load_images(imgNames))
|
||||
|
||||
print 'enter the image name to gitfiti'
|
||||
print 'images: ' + ", ".join(images.keys())
|
||||
image = raw_input(">")
|
||||
|
Reference in New Issue
Block a user