Merge pull request #5 from ohbarye/fix-1

Fix / No such file or directory: 'markdownserver/resources/css/github.css'
This commit is contained in:
Masato Ohba
2016-08-02 01:57:05 +09:00
committed by GitHub
5 changed files with 18 additions and 12 deletions
+3 -2
View File
@@ -1,14 +1,15 @@
from bottle import route,run,template,static_file from bottle import route,run,template,static_file
from markdown_converter import MarkdownConverter from markdown_converter import MarkdownConverter
from env import * from env import *
import os
converter = MarkdownConverter() converter = MarkdownConverter()
@route('/<resource>') @route('/<resource>')
def gfmize(resource): def gfmize(resource):
html_file_name = converter.convert(resource) html_file_name = os.path.basename(converter.convert(resource))
return static_file(html_file_name, root=ms_root) return static_file(os.path.join(html_dir, html_file_name), root=root_path)
def main(): def main():
run(host=ms_host,port=ms_port,debug=ms_debug,reloader=ms_reloader) run(host=ms_host,port=ms_port,debug=ms_debug,reloader=ms_reloader)
+9 -5
View File
@@ -1,12 +1,16 @@
import os
ms_encoding = 'utf-8' ms_encoding = 'utf-8'
ms_port = '8009' ms_port = '8009'
ms_host = 'localhost' ms_host = 'localhost'
ms_root = './'
ms_debug = True ms_debug = True
ms_reloader = True ms_reloader = True
html_extension = '.html' html_extension = '.html'
markdown_root = 'markdownserver/resources/markdown/' root_path = os.path.dirname(__file__)
html_root = 'markdownserver/resources/html/' resource_dir = os.path.join(root_path,'resources')
css_root = 'markdownserver/resources/css/' markdown_dir = os.path.join(resource_dir,'markdown')
html_dir = os.path.join(resource_dir,'html')
css_dir = os.path.join(resource_dir,'css')
css_name = 'github.css' css_name = 'github.css'
markdown_type = 'gfm' css_path = os.path.join(css_dir,css_name)
markdown_type = 'gfm'
+4 -3
View File
@@ -1,12 +1,13 @@
import markdown as md import markdown as md
import codecs import codecs
import sys import sys
import os
from env import * from env import *
class MarkdownConverter(object): class MarkdownConverter(object):
def __init__(self): def __init__(self):
css = codecs.open(css_root + css_name,encoding=ms_encoding,mode='r') css = codecs.open(css_path,encoding=ms_encoding,mode='r')
self.html_header = ''' self.html_header = '''
<html> <html>
<head> <head>
@@ -31,11 +32,11 @@ class MarkdownConverter(object):
return self.write_html(code,src,dst) return self.write_html(code,src,dst)
def read_md(self,file_name): def read_md(self,file_name):
md_file = codecs.open(markdown_root + file_name,encoding=ms_encoding,mode='r') md_file = codecs.open(os.path.join(markdown_dir, file_name),encoding=ms_encoding,mode='r')
return md_file.read() return md_file.read()
def write_html(self,body,file_name,dst): def write_html(self,body,file_name,dst):
html_path = html_root + file_name + html_extension html_path = os.path.join(html_root, file_name + html_extension)
if dst != "": if dst != "":
html_path = dst html_path = dst
+1 -1
View File
@@ -872,7 +872,7 @@ body .markdown-body
<body> <body>
<div class='markdown-body'> <div class='markdown-body'>
<h1>Convert Markdown to HTML with Python</h1> <h1>Convert Markdown to HTML with Python</h1>
<p>Markdown-server is a simple web application. It converts markdown file to HTML and response by text/html.</p> <p><strong>Markdown-server</strong> is a simple web application. It converts markdown file to HTML and response by text/html.</p>
<h2>Library Dependencies</h2> <h2>Library Dependencies</h2>
<table> <table>
<thead> <thead>
+1 -1
View File
@@ -37,7 +37,7 @@ setup(
], ],
entry_points = { entry_points = {
'console_scripts': [ 'console_scripts': [
'mdsvr = markdownserver:main', 'markdownserver = markdownserver:main',
'convert = markdownserver.markdown_converter:main' 'convert = markdownserver.markdown_converter:main'
] ]
}, },