Permalink
Browse files

Improved theming, the html skeleton is now modular and can be customized

  • Loading branch information...
1 parent b51c8e6 commit 8bf5f0f7766a9b585be5a23f4e03b4bec563d03c @gbrindisi committed Jul 23, 2012
Showing with 150 additions and 10 deletions.
  1. +3 −1 README.md
  2. +1 −1 wordpot.conf
  3. +0 −4 wordpot.py
  4. +5 −0 wordpot/__init__.py
  5. +135 −0 wordpot/templates/twentyeleven.html
  6. +6 −4 wordpot/views.py
View
@@ -17,12 +17,14 @@ To configure the honeypot you can edit the config file `wordpot.conf` or provide
## Theme support
-The html skeleton is stored in `templates/dummy.html` and you can use a wordpress theme as you would in a normal Wordpress installation by putting the theme folder in the `static/wp-content/themes/` directory.
+You can use a wordpress theme as you would in a normal Wordpress installation by putting the theme folder in the `static/wp-content/themes/` directory. You might also need to edit the html skeleton which is stored in the `templates/` folder and should be named as your theme (e.g. `themename.html`) - take a look at `twentyeleven.html` to see how it works.
To use the theme start wordpot with the theme option (default value is `twentyeleven`):
$ python wordpot --theme=THEMENAME
+Templates are built with the [Jinja2](http://jinja.pocoo.org) template engine.
+
## License
ISC License.
View
@@ -4,7 +4,7 @@
HOST = '127.0.0.1' # Hostname
PORT = '80' # Port
-THEME = 'twentyeleven' # Theme directory name in use
+THEME = 'twentyeleven' # Theme name in use
# -----------------------
# Wordpress configuration
View
@@ -28,10 +28,6 @@ def parse_options():
if val is not None:
app.config[opt] = val
-# Import config from file
-conffile = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'wordpot.conf')
-app.config.from_pyfile(conffile)
-
# Setup logging before execute the main
logging_setup()
View
@@ -9,6 +9,7 @@
from werkzeug.routing import BaseConverter
from wordpot.plugins_manager import PluginsManager
+import os
# ---------------
# Regex Converter
@@ -26,6 +27,10 @@ def __init__(self, url_map, *items):
app = Flask('wordpot')
app.url_map.converters['regex'] = RegexConverter
+# Import config from file
+conffile = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../wordpot.conf')
+app.config.from_pyfile(conffile)
+
# ----------------------------
# Building the plugins manager
# ----------------------------
@@ -0,0 +1,135 @@
+<!DOCTYPE html>
+<!--[if IE 6]>
+<html id="ie6" dir="ltr" lang="en-US">
+<![endif]-->
+<!--[if IE 7]>
+<html id="ie7" dir="ltr" lang="en-US">
+<![endif]-->
+<!--[if IE 8]>
+<html id="ie8" dir="ltr" lang="en-US">
+<![endif]-->
+<!--[if !(IE 6) | !(IE 7) | !(IE 8) ]><!-->
+<html dir="ltr" lang="en-US">
+<!--<![endif]-->
+{% block head %}
+<head>
+<meta charset="UTF-8" />
+<meta name="viewport" content="width=device-width" />
+<title>{{ config['BLOGTITLE'] }} | Just another WordPress site</title>
+<link rel="profile" href="http://gmpg.org/xfn/11" />
+<link rel="stylesheet" type="text/css" media="all" href="{{ url_for('static', _external=True, filename='wp-content/themes/'+config['THEME']+'/style.css') }}" />
+<link rel="pingback" href=#" />
+<!--[if lt IE 9]>
+<script src="{{ url_for('static', _external=True, filename='wp-content/themes/'+config['THEME']+'/js/html5.js') }}" type="text/javascript"></script>
+<![endif]-->
+<meta name='robots' content='noindex,nofollow' />
+<link rel="alternate" type="application/rss+xml" title="{{ config['BLOGTITLE'] }} &raquo; Feed" href="#" />
+<link rel="alternate" type="application/rss+xml" title="{{ config['BLOGTITLE'] }} &raquo; Comments Feed" href="#" />
+<link rel="EditURI" type="application/rsd+xml" title="RSD" href="#" />
+<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="#" />
+<meta name="generator" content="WordPress {{ config['VERSION'] }}" />
+ <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
+</head>
+{% endblock %}
+
+<body class="home blog single-author two-column right-sidebar">
+<div id="page" class="hfeed">
+ {% block header %}
+ <header id="branding" role="banner">
+ <hgroup>
+ <h1 id="site-title"><span><a href="/" title="{{ config['BLOGTITLE'] }}" rel="home">{{ config['BLOGTITLE'] }}</a></span></h1>
+ <h2 id="site-description">Just another WordPress site</h2>
+ </hgroup>
+ <form method="get" id="searchform" action="/">
+ <label for="s" class="assistive-text">Search</label>
+ <input type="text" class="field" name="s" id="s" placeholder="Search" />
+ <input type="submit" class="submit" name="submit" id="searchsubmit" value="Search" />
+ </form>
+
+ <nav id="access" role="navigation">
+ <h3 class="assistive-text">Main menu</h3>
+ <div class="skip-link"><a class="assistive-text" href="#content" title="Skip to primary content">Skip to primary content</a></div>
+ <div class="skip-link"><a class="assistive-text" href="#secondary" title="Skip to secondary content">Skip to secondary content</a></div>
+ <div class="menu"><ul><li class="current_page_item"><a href="/" title="Home">Home</a></li><li class="page_item page-item-2"><a href="/?page_id=2">Sample Page</a></li></ul></div>
+ </nav><!-- #access -->
+ </header><!-- #branding -->
+ {% endblock %}
+
+ <div id="main">
+
+ <div id="primary">
+ <div id="content" role="main">
+ {% block author_archives %}
+ {% if vars['AUTHORPAGE'] %}
+ <h1 class="page-title author">Author Archives: <span class="vcard"><a class="url fn n" href="?author={{ vars['CURRENTAUTHOR'][0] }}" title="{{ vars['CURRENTAUTHOR'][1] }}" rel="me">{{ vars['CURRENTAUTHOR'][1] }}</a></span></h1>
+ {% endif %}
+ {% endblock %}
+
+ {% block articles %}
+ <article id="post-1" class="post-1 post type-post status-publish format-standard hentry category-uncategorized">
+ <header class="entry-header">
+ <h1 class="entry-title"><a href="/?p=1" title="Permalink to Hello world!" rel="bookmark">Hello world!</a></h1>
+
+ <div class="entry-meta">
+ <span class="sep">Posted on </span><a href="/?p=1" title="9:57 am" rel="bookmark"><time class="entry-date" datetime="2012-06-28T09:57:14+00:00" pubdate>June 28, 2012</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="/?author=1" title="View all posts by {{ config['AUTHORS'][0] }}" rel="author">{{ config['AUTHORS'][0] }}</a></span></span>
+ </div><!-- .entry-meta -->
+
+ <div class="comments-link">
+ <a href="/?p=1#comments" title="Comment on Hello world!">1</a>
+ </div>
+ </header><!-- .entry-header -->
+
+ <div class="entry-content">
+ <p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</p>
+ </div><!-- .entry-content -->
+
+ <footer class="entry-meta">
+ <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links">Posted in</span> <a href="/?cat=1" title="View all posts in Uncategorized" rel="category">Uncategorized</a></span><span class="sep"> | </span><span class="comments-link"><a href="/?p=1#comments" title="Comment on Hello world!"><b>1</b> Reply</a></span>
+ </footer><!-- #entry-meta -->
+ </article><!-- #post-1 -->
+ {% endblock %}
+
+ </div><!-- #content -->
+ </div><!-- #primary -->
+
+ {% block sidebar %}
+ <div id="secondary" class="widget-area" role="complementary">
+ <aside id="search-2" class="widget widget_search"> <form method="get" id="searchform" action="/">
+ <label for="s" class="assistive-text">Search</label>
+ <input type="text" class="field" name="s" id="s" placeholder="Search" />
+ <input type="submit" class="submit" name="submit" id="searchsubmit" value="Search" />
+ </form>
+</aside> <aside id="recent-posts-2" class="widget widget_recent_entries"> <h3 class="widget-title">Recent Posts</h3> <ul>
+ <li><a href="/?p=1" title="Hello world!">Hello world!</a></li>
+ </ul>
+ </aside><aside id="recent-comments-2" class="widget widget_recent_comments"><h3 class="widget-title">Recent Comments</h3><ul id="recentcomments"><li class="recentcomments"><a href='http://wordpress.org/' rel='external nofollow' class='url'>Mr WordPress</a> on <a href="/?p=1#comment-1">Hello world!</a></li></ul></aside><aside id="archives-2" class="widget widget_archive"><h3 class="widget-title">Archives</h3> <ul>
+ <li><a href='/?m=201206' title='June 2012'>June 2012</a></li>
+ </ul>
+</aside><aside id="categories-2" class="widget widget_categories"><h3 class="widget-title">Categories</h3> <ul>
+ <li class="cat-item cat-item-1"><a href="/?cat=1" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+ </ul>
+</aside><aside id="meta-2" class="widget widget_meta"><h3 class="widget-title">Meta</h3> <ul>
+ <li><a href="/wp-login.php">Log in</a></li>
+ <li><a href="/?feed=rss2" title="Syndicate this site using RSS 2.0">Entries <abbr title="Really Simple Syndication">RSS</abbr></a></li>
+ <li><a href="/?feed=comments-rss2" title="The latest comments to all posts in RSS">Comments <abbr title="Really Simple Syndication">RSS</abbr></a></li>
+ <li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress.org</a></li>
+ </ul>
+ </aside>
+ </div><!-- #secondary .widget-area -->
+ {% endblock %}
+
+
+ </div><!-- #main -->
+
+ {% block footer %}
+ <footer id="colophon" role="contentinfo">
+ <div id="site-generator">
+ <a href="http://wordpress.org/" title="Semantic Personal Publishing Platform" rel="generator">Proudly powered by WordPress</a>
+ </div>
+ </footer><!-- #colophon -->
+ {% endblock %}
+</div><!-- #page -->
+
+</body>
+</html>
View
@@ -5,6 +5,8 @@
from wordpot.helpers import *
from wordpot.logger import LOGGER
+TEMPLATE = app.config['THEME'] + '.html'
+
@app.route('/', methods=['GET', 'POST'])
@app.route('/<file>.<ext>', methods=['GET', 'POST'])
def commons(file=None, ext=None):
@@ -23,9 +25,9 @@ def commons(file=None, ext=None):
LOGGER.error('Unable to run plugin: %s\n%s', p.name, e.message)
if file is None and ext is None:
- return render_template('dummy.html', vars={})
+ return render_template(TEMPLATE, vars={})
elif file == 'index' and ext == 'php':
- return render_template('dummy.html', vars={})
+ return render_template(TEMPLATE, vars={})
else:
abort(404)
@@ -75,7 +77,7 @@ def plugin(plugin, subpath='/'):
except Exception, e:
LOGGER.error('Unable to run plugin: %s\n%s', p.name, e.message)
- return render_template('dummy.html', vars={})
+ return render_template(TEMPLATE, vars={})
@app.route('/wp-content/themes/<theme>', methods=['GET', 'POST'])
@app.route('/wp-content/themes/<theme><regex("(\/.*)"):subpath>', methods=['GET', 'POST'])
@@ -101,5 +103,5 @@ def theme(theme, subpath='/'):
except Exception, e:
LOGGER.error('Unable to run plugin: %s\n%s', p.name, e.message)
- return render_template('dummy.html', vars={})
+ return render_template(TEMPLATE, vars={})

0 comments on commit 8bf5f0f

Please sign in to comment.