Skip to content

Commit

Permalink
Merge pull request gelstudios#4 from empathetic-alligator/master
Browse files Browse the repository at this point in the history
Implemented support for user templates
  • Loading branch information
gelstudios committed May 22, 2013
2 parents 3ad59a2 + 4903cda commit 6c4020a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,39 @@ 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).

---
####Todo:
- ~~Remove 'requests' dependency~~
- Web interface
- Load "art" from a file
- ~~Load "art" from a file~~
- Load commit content from a file
- ...
- Profit?
Expand Down
29 changes: 29 additions & 0 deletions gitfiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,30 @@
'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/'
Expand Down Expand Up @@ -165,6 +189,7 @@ def save(output, filename):
f.close()

def main():
global images
print '''
_ __ _____ __ _
____ _(_) /_/ __(_) /_(_)
Expand All @@ -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(">")
Expand Down

0 comments on commit 6c4020a

Please sign in to comment.