Skip to content

Commit

Permalink
gitology-blog-document first pass done
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit Upadhyay committed Jan 14, 2009
1 parent 27db9c0 commit 685c676
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gitology-sample-repo/documents/asd/meta.json
@@ -1 +1 @@
{"author": "www.amitu.com"}
{"author": "www.amitu.com", "title": "ASD rules the world"}
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -10,6 +10,7 @@
'src/tools/gitology-init',
'src/tools/gitology-info',
'src/tools/gitology-blog-start',
'src/tools/gitology-blog-document',
'src/tools/gitology-wiki-document',
],

Expand Down
8 changes: 6 additions & 2 deletions src/gitology/blog.py
Expand Up @@ -9,8 +9,12 @@ def blog_document(document, url, blog="main", dtime=None):
).joinpath(blog).joinpath("%04d" % dtime.year).joinpath(
"%02d" % dtime.month
).joinpath("%02d.lst" % dtime.day)
# blog_file.makedirs()
if not blog_file.parent.exists(): blog_file.parent.makedirs()
if not blog_file.parent.exists():
blog_file.parent.makedirs()
blog_file.open("a+").write(
"%s %s %s\n" % (url, document.name, str(dtime))
)
for label in document.meta.get("labels", []):
gsettings.LOCAL_REPO_PATH.joinpath(
"blogs/%s/labels/%s.lst" % (blog, label)
).open("a+").write("%s\n" % url)
1 change: 1 addition & 0 deletions src/gitology/utils.py
Expand Up @@ -154,6 +154,7 @@ def get_blog(p):
)
from django.contrib.syndication.feeds import Feed
class LatestEntries(Feed):
print b["document"].name
title = b["document"].meta.title
link = b["document"].meta.title
description = b["document"].meta.subtitle
Expand Down
74 changes: 74 additions & 0 deletions src/tools/gitology-blog-document
@@ -0,0 +1,74 @@
"""
post some document
"""
# imports
import sys, gitology, os, path
from optparse import OptionParser

from gitology import utils, blog
from gitology.config import settings as gsettings
from gitology.document import Document
# }}}

# build_parser # {{{
def build_parser():
parser = OptionParser(
version = "%prog " + gitology.VERSION,
usage = "Usage: %prog [options] [repository_folder_location]",
)
parser.add_option(
"--blog", action="store", dest="blog_name", default="main",
help="Post will appear in this BLOG_NAME blog. Default=main"
)
parser.add_option(
"-u", "--url", action="store", dest="url",
help="post would appear at this URL"
)
parser.add_option(
"--about", action="callback", callback=print_about,
help="find out more about this script"
)
return parser
# }}}


# print_about # {{{
def print_about(*args, **kw):
print utils.smart_wrap(
"""post a document on the blog"""
)
raise SystemExit
# }}}

def main():
parser = build_parser()
(options, args) = parser.parse_args()
if len(args) > 1:
parser.error("Please specify only one document name.")
if len(args) == 0:
try:
doc_name = raw_input("Please enter the document's name: ")
except KeyboardInterrupt:
print
return 1
else:
doc_name = args[0]
post_doc = Document(doc_name)
if not post_doc.exists():
print "Document does not exists"
return 2

if not options.url:
try:
url = raw_input(
"Please enter URL: "
)
except KeyboardInterrupt:
print
return 1
else: url = options.url
blog.blog_document(post_doc, url, options.blog_name)
return 0

if __name__ == "__main__":
sys.exit(main())
Empty file.

0 comments on commit 685c676

Please sign in to comment.