From 12d29ee56176c62f767027d3f25386911c45bd9a Mon Sep 17 00:00:00 2001 From: William Povell Date: Tue, 21 May 2013 21:34:27 -0400 Subject: [PATCH 1/6] Implemented support for user images. --- gitfiti.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gitfiti.py b/gitfiti.py index 61cc45e47..ee1f6cd0d 100755 --- a/gitfiti.py +++ b/gitfiti.py @@ -87,6 +87,31 @@ images={ 'hireme':hireme } +def load_images(imgNames): + """loads user images from given file(s)""" + for imageName in imgNames: + img = open(imageName) + loadedImgs = {} + first = True + imgList = '' + imgLine = ' ' + name = img.readline().replace('\n', '') + name = name[1:] + + while True: + imgLine = img.readline().replace('\n', '') + if imgLine == '': + break + if(imgLine[0] == ':'): + loadedImgs[name] = json.loads(imgList) + name = imgLine[1:] + imgList = '' + else: + imgList += imgLine + loadedImgs[name] = json.loads(imgList) + print(loadedImgs) + return loadedImgs + def get_calendar(username): """retrieves the github commit calendar data for a username""" BASEURL='https://github.com/' @@ -165,6 +190,7 @@ def save(output, filename): f.close() def main(): + global images print ''' _ __ _____ __ _ ____ _(_) /_/ __(_) /_(_) @@ -186,6 +212,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(">") From 140cef972a76007e6cbba85fbbb2d2012bdac352 Mon Sep 17 00:00:00 2001 From: William Povell Date: Tue, 21 May 2013 21:37:46 -0400 Subject: [PATCH 2/6] Removed a debug line I forgot about --- gitfiti.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gitfiti.py b/gitfiti.py index ee1f6cd0d..3e471673c 100755 --- a/gitfiti.py +++ b/gitfiti.py @@ -109,7 +109,6 @@ def load_images(imgNames): else: imgList += imgLine loadedImgs[name] = json.loads(imgList) - print(loadedImgs) return loadedImgs def get_calendar(username): From 8e3cb8e37fe6573cf7f47ae9f854e70573c253c0 Mon Sep 17 00:00:00 2001 From: William Povell Date: Tue, 21 May 2013 21:38:31 -0400 Subject: [PATCH 3/6] Removed an unused variable. --- gitfiti.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gitfiti.py b/gitfiti.py index 3e471673c..5a7bf50f6 100755 --- a/gitfiti.py +++ b/gitfiti.py @@ -92,7 +92,6 @@ def load_images(imgNames): for imageName in imgNames: img = open(imageName) loadedImgs = {} - first = True imgList = '' imgLine = ' ' name = img.readline().replace('\n', '') From 599358d30c2a7dd8a82dea5db52e3bd37a4fc597 Mon Sep 17 00:00:00 2001 From: William Povell Date: Tue, 21 May 2013 21:53:47 -0400 Subject: [PATCH 4/6] Changed README.md to described added functionality. Also edited gitfiti.py to accept template files with newlines between templates. --- README.md | 25 ++++++++++++++++++++++++- gitfiti.py | 3 ++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5bfc49411..e8e17db23 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,29 @@ 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 +50,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? diff --git a/gitfiti.py b/gitfiti.py index 5a7bf50f6..8e5e69d65 100755 --- a/gitfiti.py +++ b/gitfiti.py @@ -98,9 +98,10 @@ def load_images(imgNames): name = name[1:] while True: - imgLine = img.readline().replace('\n', '') + imgLine = img.readline() if imgLine == '': break + imgLine.replace('\n', '') if(imgLine[0] == ':'): loadedImgs[name] = json.loads(imgList) name = imgLine[1:] From 94b53214685fe9f4fec0fb41a3dfeb7e495d99b2 Mon Sep 17 00:00:00 2001 From: William Povell Date: Tue, 21 May 2013 21:55:18 -0400 Subject: [PATCH 5/6] Put example template in code block. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e8e17db23..4df96be91 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ The file format for personal templates is the following: For example: +''' :center-blank [[1,1,1,1,1,1,1], [1,1,1,1,1,1,1], @@ -38,6 +39,7 @@ For example: [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. From 4903cda740133b5c3c19b85ad34acf29f0647f5e Mon Sep 17 00:00:00 2001 From: William Povell Date: Tue, 21 May 2013 21:56:01 -0400 Subject: [PATCH 6/6] Fixed code block formatting. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4df96be91..e91b35262 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The file format for personal templates is the following: For example: -''' +``` :center-blank [[1,1,1,1,1,1,1], [1,1,1,1,1,1,1], @@ -39,7 +39,7 @@ For example: [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.