PK!driftdeck/__init__.pyPK!yLLdriftdeck/__main__.pyif __name__ == '__main__': from driftdeck.core import start start() PK!O driftdeck/core.py""" Drift Deck Usage: driftdeck [--css ] driftdeck (-h | --help) driftdeck --version Options: --css Provide your custom css for markdown -h --help Show this screen. --version Show version. """ import os import webbrowser from io import open from string import Template from pkg_resources import resource_string, get_distribution from docopt import docopt from markdown import markdown from driftdeck.httpd import ThreadedHTTPServer def convert(title: str, md: str, slide: int, total: int) -> str: """ :param md: the markdown of one slide :param slide: number of the slide :param total: total number of slides :return: """ html = markdown(md, extensions=['markdown.extensions.extra', 'markdown.extensions.codehilite', 'markdown.extensions.nl2br', 'markdown.extensions.sane_lists', 'markdown.extensions.smarty']) numbers = ''.join(['%d' % (' class="active"' if i == slide else '', i) for i in range(1, total + 1)]) return Template(resource_string(__name__, 'slide.html').decode()) \ .safe_substitute(dict(title=title, content=html, numbers=numbers, total=total, a_prev='<' % (slide - 1) if slide > 1 else '', a_next='>' % (slide + 1) if slide < total else '', prev=slide - 1 if slide > 1 else 1, next=slide + 1 if slide < total else total)) def start(): args = docopt(__doc__, version='Drift Deck v%s' % get_distribution('driftdeck').version) if args['--css'] and os.path.isfile(args['--css']): with open(args['--css'], 'r') as fd: custom_css = fd.read() else: custom_css = None markupfile = os.path.expanduser(args['']) title = os.path.basename(markupfile) with open(markupfile, 'r') as fd: mdslides = fd.read().split('---\n') htmlslides = [] for i, slide in enumerate(mdslides, start=1): htmlslides.append(convert(title, slide, int(i), len(mdslides))) del mdslides with ThreadedHTTPServer(slides=htmlslides, css=custom_css) as s: webbrowser.open('http://localhost:%d/1' % s.server.server_port) input('Running presentation, press to quit...') PK!ӕNCCdriftdeck/httpd.pyfrom http.server import BaseHTTPRequestHandler, HTTPServer from threading import Thread from typing import List from pkg_resources import resource_string class RequestHandler(BaseHTTPRequestHandler): def do_GET(self): path = self.path.split('?')[0][1:] if path.isnumeric() and int(path) > 0: self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() for line in self.server.slides[int(path) - 1].split('\n'): self.wfile.write(line.encode('utf-8')) elif self.path == '/style.css': self.send_response(200) self.send_header('Content-type', 'text/css') self.end_headers() self.wfile.write(resource_string(__name__, 'style.css')) elif self.path == '/custom.css' and self.server.custom_css: self.send_response(200) self.send_header('Content-type', 'text/css') self.end_headers() for line in self.server.custom_css.split('\n'): self.wfile.write(line.encode('utf-8')) else: self.send_response(404) def log_message(self, *args): """ Silencing log output """ pass class ThreadedHTTPServer(): def __init__(self, slides: List[str], css: str = None): """ :param slides: list of strings containing the html content of the slides """ self.server = HTTPServer(('127.0.0.1', 0), RequestHandler) self.server.slides = slides self.server.custom_css = css self.server_thread = Thread(target=self.server.serve_forever) self.server_thread.daemon = True def start(self) -> int: """ :return: returns the port number of the web server """ self.server_thread.start() return self.server.server_port def stop(self): self.server.shutdown() self.server.server_close() def __enter__(self): self.start() return self def __exit__(self, type, value, traceback): self.stop() PK!Ŗ]kkdriftdeck/slide.html $title
$content
$a_prev
$numbers
$a_next
PK!;'driftdeck/style.cssh1, h2, h3, h4, h5, h6, p, blockquote { margin: 0; padding: 0; } body { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px; color: #fff; background-color: #110F14; margin: 10px 13px 10px 13px; } table { margin: 10px 0 15px 0; border-collapse: collapse; } td,th { border: 1px solid #ddd; padding: 3px 10px; } th { padding: 5px 10px; } a { color: #59acf3; } a:hover { color: #a7d8ff; text-decoration: none; } a img { border: none; } p { margin-bottom: 9px; } h1, h2, h3, h4, h5, h6 { color: #fff; line-height: 36px; } h1 { margin-bottom: 18px; font-size: 30px; } h2 { font-size: 24px; } h3 { font-size: 18px; } h4 { font-size: 16px; } h5 { font-size: 14px; } h6 { font-size: 13px; } hr { margin: 0 0 19px; border: 0; border-bottom: 1px solid #ccc; } blockquote { padding: 13px 13px 21px 15px; margin-bottom: 18px; font-family:georgia,serif; font-style: italic; } blockquote:before { content:"\201C"; font-size:40px; margin-left:-10px; font-family:georgia,serif; color:#eee; } blockquote p { font-size: 14px; font-weight: 300; line-height: 18px; margin-bottom: 0; font-style: italic; } code, pre { font-family: Menlo, Monaco, Andale Mono, Courier New, monospace; } code { padding: 1px 3px; font-size: 12px; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; background: #334; } pre { display: block; padding: 14px; margin: 0 0 18px; line-height: 16px; font-size: 11px; border: 1px solid #334; white-space: pre; white-space: pre-wrap; word-wrap: break-word; background-color: #282a36; border-radius: 6px; } pre code { font-size: 11px; padding: 0; background: transparent; } sup { font-size: 0.83em; vertical-align: super; line-height: 0; } * { -webkit-print-color-adjust: exact; } @media screen and (min-width: 914px) { body { width: 854px; margin:10px auto; } } @media print { body,code,pre code,h1,h2,h3,h4,h5,h6 { color: black; } table, pre { page-break-inside: avoid; } }PK!H1H,2*driftdeck-0.3.2.dist-info/entry_points.txtN+I/N.,()J)L+IIMζRKJPK!3Wt--!driftdeck-0.3.2.dist-info/LICENSEMIT License Copyright (c) 2018 Ricardo Band Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!H2ʍTTdriftdeck-0.3.2.dist-info/WHEEL 1 0 =Rn>ZD:_dhRUQTk=-k]m`Q'iPK!Hs J "driftdeck-0.3.2.dist-info/METADATAVmo6_q@a,)mnnƒư `<[\(#°ӛ y{ٗ`ſ $ E[qrfeQ0We00" 0 +d0e%2U+),CTR),xtI[&ygiAeM\;}ϣ'|3h:Ѱ qL%gNDB1L \ H5`ǓTN8r%B!bDރ{nl7 cP 0,Dͱv!+cDY~]S|:B}2+?̑(xN#s4T driftdeck-0.3.2.dist-info/RECORD}ǒP}? 䰘$JZ7Dlb6:(;@PULWTgo!Κr>:[~+oԮm6Tz)]f쩗yӸD,Yf8´xnc38̠2Ӧۤvz_vQadTFi`KQBh6<<в_JAsAJ-(?-#E솂 ]i[b]#>9](\.JXY#ibhm] */*a+ɽXi,kM71󘽠u ۾;zG2;\;wBHz+p m:IŀNUF^HK| Y=yu*:Z q5Оtl1Ip9Uvipe~ D ޫߛ V}I| G Uݞ𢙵>5jpk#kǔ6p=1?]U0/PK!driftdeck/__init__.pyPK!yLL3driftdeck/__main__.pyPK!O driftdeck/core.pyPK!ӕNCC driftdeck/httpd.pyPK!Ŗ]kk.driftdeck/slide.htmlPK!;'driftdeck/style.cssPK!H1H,2*|!driftdeck-0.3.2.dist-info/entry_points.txtPK!3Wt--!!driftdeck-0.3.2.dist-info/LICENSEPK!H2ʍTT\&driftdeck-0.3.2.dist-info/WHEELPK!Hs J "&driftdeck-0.3.2.dist-info/METADATAPK!H>4T *driftdeck-0.3.2.dist-info/RECORDPK -