-
-
Save SonOfLilit/a4573918d76c920bd34c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
HTML = """<?doctype html> | |
<html> | |
<head> | |
<style> | |
body { | |
background-color: gray; | |
} | |
// ... | |
.cl { | |
clear: left; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>The Business Model Canvas</h1> | |
<h2>Designed for: %%s</h2> | |
<h2>Designed by: Aur Saraf</h2> | |
<table> | |
<tr> | |
<td rowspan="2"> | |
<h3>Key Partners</h3> | |
%(partners)s | |
</td> | |
<td> | |
<h3>Key Activities</h3> | |
%(activities)s | |
</td> | |
<td colspan="2" rowspan="2"> | |
<h3>Value Propositions</h3> | |
%(values)s | |
</td> | |
</tr> | |
<!-- ... --!> | |
</table> | |
<!-- ... --!> | |
</body> | |
</html> | |
""" | |
POSTIT = '<div class="postit %(classes)s">%(content)s</div>' | |
CANVAS_CODE = """CANVAS = { | |
"customers": [], | |
"values": [], | |
"channels": [], | |
"relationships": [], | |
"revenues": [], | |
"resources": [], | |
"activities": [], | |
"partners": [], | |
"costs": [], | |
} | |
""" | |
def to_postit(caption): | |
classes = "" | |
if caption.startswith(" "): | |
classes = "cl " | |
caption = caption[1:] | |
return POSTIT % {"classes": classes, "content": caption} | |
def write(name, canvas, f): | |
canvas = dict((k, "\n".join(map(to_postit, v))) for k, v in canvas.iteritems()) | |
html = HTML % canvas % name | |
f.write(html) | |
def main(): | |
if len(sys.argv) == 3 and sys.argv[1] == "-new": | |
with file(sys.argv[2] + ".py", "wb") as f: | |
f.write(CANVAS_CODE) | |
return 0 | |
elif len(sys.argv) != 2: | |
print "usage: canvas.py name" | |
return 1 | |
name = sys.argv[1] | |
module = __import__(name) | |
with file(name + ".html", "wb") as f: | |
write(name, module.CANVAS, f) | |
return 0 | |
if __name__ == '__main__': | |
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python canvas.py -new geekar | |
$ emacs geekar.py | |
$ python canvas.py geekar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment