Skip to content

Commit

Permalink
Merge 4125dbe into f1fceba
Browse files Browse the repository at this point in the history
  • Loading branch information
duoduo369 committed Jun 22, 2014
2 parents f1fceba + 4125dbe commit 7e56f0d
Show file tree
Hide file tree
Showing 21 changed files with 375 additions and 30 deletions.
9 changes: 4 additions & 5 deletions simiki/cli.py
Expand Up @@ -40,8 +40,7 @@
from simiki.configs import parse_configs
from simiki.log import logging_init
from simiki.server import preview
from simiki.utils import (check_path_exists, copytree, emptytree,
check_extension, mkdir_p)
from simiki.utils import (copytree, emptytree, check_extension, mkdir_p)
from simiki import __version__

logger = logging.getLogger(__name__)
Expand All @@ -68,7 +67,7 @@ def write_file(content, ofile, ftype="page"):
"""
if ftype == "page":
output_category, _ = os.path.split(ofile)
if not check_path_exists(output_category):
if not os.path.exists(output_category):
logging.info(
"The output category %s not exists, create it"
% output_category
Expand All @@ -91,12 +90,12 @@ def create_new_wiki(source, category, filename, title, date):
sys.exit(1)

category_path = os.path.join(source, category)
if not check_path_exists(category_path):
if not os.path.exists(category_path):
os.mkdir(category_path)
logger.info("Creating category {}.".format(category))

fn = os.path.join(category_path, filename)
if check_path_exists(fn):
if os.path.exists(fn):
logger.warning("wiki file exists: {}".format(fn))
else:
logger.info("Creating wiki: {}".format(fn))
Expand Down
3 changes: 1 addition & 2 deletions simiki/configs.py
Expand Up @@ -9,7 +9,6 @@
from copy import deepcopy
from pprint import pprint
import yaml
from simiki.utils import check_path_exists


def _set_default_configs():
Expand Down Expand Up @@ -46,7 +45,7 @@ def _post_process(configs):
def parse_configs(config_file):
default_configs = _set_default_configs()

if not check_path_exists(config_file):
if not os.path.exists(config_file):
logging.error("{} not exists".format(config_file))
sys.exit(1)

Expand Down
9 changes: 4 additions & 5 deletions simiki/initsite.py
Expand Up @@ -10,15 +10,14 @@

from simiki.configs import parse_configs
from simiki.log import logging_init
from simiki.utils import (check_path_exists, copytree, mkdir_p,
listdir_nohidden)
from simiki.utils import (copytree, mkdir_p, listdir_nohidden)


class InitSite(object):

def __init__(self, config_file, target_path):
self.config_file = config_file
if not check_path_exists(self.config_file):
if not os.path.exists(self.config_file):
logging.error("{} not exists".format(self.config_file))
sys.exit(1)
try:
Expand All @@ -29,13 +28,13 @@ def __init__(self, config_file, target_path):
self.target_path = target_path

def get_file(self, src, dst):
if check_path_exists(dst):
if os.path.exists(dst):
logging.warning("{} exists".format(dst))
return

# Create parent directory
dst_directory = os.path.dirname(dst)
if not check_path_exists(dst_directory):
if not os.path.exists(dst_directory):
mkdir_p(dst_directory)
logging.info("Creating directory: {}".format(dst_directory))

Expand Down
4 changes: 2 additions & 2 deletions simiki/server.py
Expand Up @@ -3,12 +3,12 @@
from __future__ import print_function, absolute_import

import os
import os.path
import sys
import logging
import SimpleHTTPServer
import SocketServer

from simiki.utils import check_path_exists

logger = logging.getLogger(__name__)

Expand All @@ -18,7 +18,7 @@ class Reuse_TCPServer(SocketServer.TCPServer):


def preview(path, port=8000):
if check_path_exists(path):
if os.path.exists(path):
os.chdir(path)
else:
logger.error("Path {} not exists".format(path))
Expand Down
26 changes: 26 additions & 0 deletions simiki/themes/bootstrap3/base.html
@@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html>
<head>
<link rel="Stylesheet" type="text/css"
href="{{ site.root }}/static/css/bootstrap.min.css">
<title>{% block title %}{% endblock %}</title>
<meta name="keywords" content="{{ site.keywords }}"/>
<meta name="description" content="{{ site.description }}"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="container">
{% block container %}
{% endblock %}
<footer class="footer">
Copyright © 2012-2014 {{ site.author }}.
Powered by <a href="http://simiki.org/" target="_blank">Simiki</a>.
</footer>
</div>
{% include "stat.html" %}
<script type="text/javascript" src="{{ site.root }}/static/js/jquery-1.11.1.min.js">
</script>
<script type="text/javascript" src="{{ site.root }}/static/js/bootstrap.min.js">
</script>
</body>
</html>
26 changes: 26 additions & 0 deletions simiki/themes/bootstrap3/index.html
@@ -0,0 +1,26 @@
{% extends "base.html" %}

{% block title %}{{ site.title }}{% endblock %}

{% block container %}
<div id="wiki_title">{{ site.title }}</div>

{% if site.index %}
{{ page.content }}
{% else %}
{% for category_name, pages in site.structure.iteritems() %}
{# Only list second-level directory #}
{% if site.default_ext not in category_name %}
<h2 id="{{ category_name }}">{{ category_name }}</h2>
<ul>
{%- for page_file, page_metadata in pages.iteritems() %}
{% if site.default_ext in page_file %}
<li class="pagelist"><a href="./{{ category_name }}/{{ page_metadata.name }}.html">{{ page_metadata.title }}</a></li>
{% endif %}
{%- endfor %}
</ul>
{% endif %}
<div class="clearfix"></div>
{% endfor %}
{% endif %}
{% endblock %}
24 changes: 24 additions & 0 deletions simiki/themes/bootstrap3/page.html
@@ -0,0 +1,24 @@
{% extends "base.html" %}

{% block title %}{{ page.title }} - {{ site.title }}{% endblock %}

{% block container %}
<header>
<ol class="breadcrumb">
{% if not default_home_page %}
<li><a href="{{ site.root }}/">Home</a></li>
{%- if page.category %}
<li><a href="{{ site.root }}/#{{ page.category }}">{{ page.category }}</a></li>
{%- endif %}
<li>{{ page.title }}</li>
{% endif %}
</ol>
</header>
<div class="clearfix"></div>
<div class="jumbotron">
<h1>{{ page.title }}</h1>
</div>
<div class="content">
{{ page.content }}
</div>
{% endblock %}
Empty file.
7 changes: 7 additions & 0 deletions simiki/themes/bootstrap3/static/css/bootstrap.min.css

Large diffs are not rendered by default.

Binary file not shown.

0 comments on commit 7e56f0d

Please sign in to comment.