Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #60 from pickle27/master
Browse files Browse the repository at this point in the history
fix the markdown pages
  • Loading branch information
Soeren Sonnenburg committed Mar 29, 2014
2 parents 815047b + 1b5d2ac commit 9fbd8ff
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions README
Expand Up @@ -7,6 +7,13 @@ Adding Content
From the admin page create a new ShogunPage and then create a new article that links to it.
You will also need to edit the navbar to add your new page to the navbar

Adding Markdown pages from GitHub
run:

PYTHONPATH=. util/gfmarkdown.py -d <path to shogun repo>

from the shogun web / directory to get the latest markdown files and prepare them for the website

Explanation of directory content
================================

Expand Down
9 changes: 7 additions & 2 deletions pages/views.py
Expand Up @@ -310,6 +310,11 @@ def markdown(request, mdfile):
error(err)

page='documentation'

# hack for nested markdown
if mdfile == 'doc':
mdfile = request.path.split('/')[-1]

markdown_requested=mdfile.replace('.md','')

try:
Expand All @@ -318,8 +323,8 @@ def markdown(request, mdfile):
except IOError, err:
error(err)

return HttpResponse(template.render(Context({'current_page_path' : page,
'current_subpage_path' : markdown_requested,
return HttpResponse(template.render(Context({
'current_page' : fake_page(page +'/' + markdown_requested),
'navbar' : navbar,
'html_fname' : "md2html/%s.html" % markdown_requested})))

Expand Down
6 changes: 5 additions & 1 deletion util/gfmarkdown.py
Expand Up @@ -6,7 +6,7 @@
from shogun.settings import SRC_DIR
except ImportError:
print 'Module shogun.settings not found. Add the root directory of shogun-web to the PYTHONPATH.'
print 'For instance, from shogun-web\'s root directory do: PYTHONPATH=. util/markdown.py'
print 'For instance, from shogun-web\'s root directory do: PYTHONPATH=. util/gfmarkdown.py'
sys.exit(0)

try:
Expand All @@ -16,16 +16,20 @@
print 'or see the documentation at http://jacquev6.github.io/PyGithub/.'
sys.exit(0)


def print_help():
print 'markdown.py -d <root directory to recursively look for md files>'


def get_html_from_md(md_fname):
md_file = open(md_fname, 'r')
md_content = md_file.read()
md_file.close()
g = Github()
return g.render_markdown(md_content)


# Main
if __name__ == "__main__":
rootdir = SRC_DIR

Expand Down

0 comments on commit 9fbd8ff

Please sign in to comment.