Skip to content

Commit

Permalink
improved static pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Fiers committed Nov 22, 2012
1 parent 0d739f1 commit e289c81
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 16 deletions.
20 changes: 16 additions & 4 deletions moa/plugin/system/doc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ def _writeMessage(category, txt, title=None):
category, now.year, now.month, now.day,
now.hour, now.minute, now.second))

if title is None:
title = txt[0]
while txt[0].strip() == "":
txt = txt[1:]

if title is None or title.strip() == "":
title = '%s %d/%d/%d %d:%d:%d' % (
category, now.year, now.month, now.day,
now.hour, now.minute, now.second)

txt = "\n".join(txt).rstrip() + "\n"

#:date: 2010-10-03 10:20
Expand Down Expand Up @@ -127,6 +131,7 @@ def _readFromuser(job, ):

@moa.args.needsJob
@moa.args.argument('message', nargs='*')
@moa.args.argument('-t', '--title', help='mandatory job title')
@moa.args.command
def blog(job, args):
"""
Expand All @@ -149,6 +154,9 @@ def blog(job, args):
.. _Markdown: http://daringfireball.net/projects/markdown/ markdown.
"""

if args.title is None:
moa.ui.exitError("Please provide a blog title using -t")

sin = _getFromStdin()

if args.message:
Expand All @@ -161,7 +169,7 @@ def blog(job, args):
message.append("\nStdin:\n")
message.extend([" " + x for x in sin.split("\n")])

_writeMessage('blog', message)
_writeMessage('blog', message, title=args.title)

moa.ui.message("Created a blog entry", store=False)
sysConf.doc.blog = "\n".join(message)
Expand Down Expand Up @@ -261,6 +269,7 @@ def _show_stuff(category, no_messages):

@moa.args.needsJob
@moa.args.argument('message', nargs='*')
@moa.args.argument('-t', '--title', help='mandatory job title')
@moa.args.command
def change(job, args):
"""
Expand Down Expand Up @@ -309,14 +318,16 @@ def change(job, args):
message.append("\nStdin:\n")
message.extend([" " + x for x in sin.split("\n")])

_writeMessage('change', message)
_writeMessage('change', message, title=args.title)

moa.ui.message("Created a changelog entry", store=False)
sysConf.doc.changeMessage = "\n".join(message)


@moa.args.doNotLog
@moa.args.needsJob
#@moa.args.addFlag('-r', '--recursive', help='run recursively - ' +
# 'including all subdirectories')
@moa.args.command
def pelican(job, args):
"""
Expand Down Expand Up @@ -346,6 +357,7 @@ def pelican(job, args):
pelican_util.generate_file_page(job)
pelican_util.generate_readme_page(job)
pelican_util.generate_template_page(job)
pelican_util.generate_directory_page(job)

jtemplate = jenv.select_template(['pelican.conf.jinja2'])

Expand Down
23 changes: 23 additions & 0 deletions moa/plugin/system/doc/pelican_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,29 @@ def generate_parameter_page(job):
}))


def generate_directory_page(job):
"""
Create a parameter page for pelican
"""

jtemplate = jenv.select_template(['localdir.page.jinja2'])
pagename = _getpagename('localdir.md')

#get local file listing
data = dict([(x, os.stat(x))
for x
in os.listdir(job.wd)
if not x[0] == '.'])

files = sorted(data.keys())

with open(pagename, 'w') as F:
F.write(jtemplate.render({
'files': files,
'data': data
}))


def generate_file_page(job):
"""
Prepare a list of files for display
Expand Down
6 changes: 3 additions & 3 deletions moa/plugin/system/doc/templates/file.page.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Set | Input | Output |
{%- if fset.input|length <= i -%}
{{ ' |' }}
{%- else -%}{% set f=fset['input'][i] -%}
[{{f[3]}}]({{ f[3] }}) / [&psi;]({{ f[3] }}/index.html) / [{{ f[4] }}]({{ f[2] }}) |
[{{f[3]}}](../../../../{{ f[3] }}) / [&psi;](../../../../{{ f[3] }}/index.html) / [{{ f[4] }}](../../../../{{ f[2] }}) |
{%- endif -%}
{%- if fset.output|length <= i -%}
{{ ' |' }}
{%- else -%}{% set f=fset['output'][i] -%}
[{{f[3]}}]({{ f[3] }}) / [&psi;]({{ f[3] }}/index.html) / [{{ f[4] }}]({{ f[2] }})
[{{f[3]}}](../../../../{{ f[3] }}) / [&psi;](../../../../{{ f[3] }}/index.html) / [{{ f[4] }}](../../../../{{ f[2] }})
{%- endif -%}
{{ '\n' }}
{%- endfor -%}
{%- endfor %}
{%- endfor -%}

21 changes: 19 additions & 2 deletions moa/plugin/system/doc/templates/pelican.conf.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,25 @@ CONTENT_STATIC_LOC = '../../../'
MD_EXTENSIONS = ['tables', 'def_list']
SUMMARY_MAX_LENGTH = 50

LINKS = (('Moa docs', 'http://mfiers.github.com/Moa/'),
('Moa source', 'https://github.com/mfiers/Moa'),
ARTICLE_URL = '{slug}.html'
ARTICLE_SAVE_AS = '{slug}.html'
PAGE_URL = 'pages_{slug}.html'
PAGE_SAVE_AS = 'pages_{slug}.html'
PAGE_LANG_URL = 'pages_{slug}-{lang}.html'
PAGE_LANG_SAVE_AS = 'pages_{slug}-{lang}.html'
AUTHOR_URL = 'author_{name}.html'
AUTHOR_SAVE_AS = 'author_{name}.html'
CATEGORY_URL = 'category_{name}.html'
CATEGORY_SAVE_AS ='category_{name}.html'
TAG_URL = 'tag_{name}.html'
TAG_SAVE_AS = 'tag_{name}.html'

FEED_ATOM = None
FEED_RSS = None

LINKS = (('Moa', 'http://moa.rtfd.org/'),
('Source', 'https://github.com/mfiers/Moa'),
('Issues', 'https://github.com/mfiers/Moa/issues'),
)


2 changes: 1 addition & 1 deletion moa/plugin/system/doc/templates/redirect.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<title>Moa pelican page for {{ WD }}</title>
<meta http-equiv="REFRESH" content="0;url=./.moa/doc/pelican/index.html"></HEAD>
<meta http-equiv="REFRESH" content="0;url=./.moa/doc/pelican/pages_directory.html"></HEAD>
<BODY>
..should have redirected...
</BODY>
Expand Down
5 changes: 3 additions & 2 deletions moa/plugin/system/doc/theme/static/bootstrap.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions moa/plugin/system/doc/theme/static/local.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.moaDoesNotExist {
color: gray;
cursor: default;

}

body { padding-top: 60px; }
div.article { padding-top: 20px; }
div.article h2 { padding-bottom: 10px; }
Expand All @@ -16,6 +22,9 @@ div.highlight pre {
font-size: 10px;
}

table th, table td {
padding: 4px;
}
.summary * { display: inline; }
.summary pre { display: none; }

Expand Down
6 changes: 3 additions & 3 deletions moa/plugin/system/doc/theme/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<script src="{{ SITEURL }}/theme/html5.js"></script>
<![endif]-->

<script src="{{ SITEURL }}/theme/moa.js"></script>
<link rel="shortcut icon" href="{{ SITEURL }}/theme/images/icons/favicon.ico" />
<link href="{{ SITEURL }}/theme/bootstrap.min.css" rel="stylesheet" />
<link href="{{ SITEURL }}/theme/local.css" rel="stylesheet" />
Expand All @@ -24,7 +25,7 @@
<img src="{{SITEURL}}/theme/images/moa.logo.very.small.png">
{{ SITENAME }} | {{ MOATEMPLATE }} | <b> {{ TITLE }} </b> | </a>
<ul class="nav">
<li><a href="{% block jobdir %}../../{% endblock %}">{{WD}}</a></li>
<li><a href="{% block jobdir %}../../../{% endblock %}">{{WD}}</a></li>
</ul>
<p class="pull-right"><a href="{{ SITEURL }}/archives.html">[archives]</a> <a href="{{ SITEURL }}/tags.html">[tags]</a></p>
</div>
Expand All @@ -36,7 +37,6 @@
<div class="well">
<h3>Job</h3>
<ul>
<li><a href="{{ self.jobdir() }}">dir</a>
{% for title, link in MENUITEMS %}
<li><a href="{{ link }}">{{ title }}</a></li>
{% endfor %}
Expand Down Expand Up @@ -66,7 +66,7 @@ <h3>Links</h3>
{% block indextitle %}<div class="page-header"><h1>{% block title %} {{ self.windowtitle() }} {% endblock %}</h1></div>{% endblock %}
{% block content %}{% endblock %}
<footer>
<p> Powered by <a href="http://alexis.notmyidea.org/pelican/">Pelican</a>, theme based on <a href="http://twitter.github.com/bootstrap/">Bootstrap from Twitter</a>&copy; {{ AUTHOR }} 2011</p>
<p style="font-size: 7px;"> Powered by <a href="http://moa.rtfd.org/">Moa</a>. Page generated by <a href="http://alexis.notmyidea.org/pelican/">Pelican</a></p>
</footer>
</div>

Expand Down
1 change: 0 additions & 1 deletion moa/plugin/system/doc/theme/templates/page.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "base.html" %}
{% block jobdir %}../../../{% endblock %}
{% block indextitle %}{% endblock %}
{% block content %}
<div class='page'>
Expand Down

0 comments on commit e289c81

Please sign in to comment.