From e8ce0a868846718e85b1faddc6b0a2215081d83e Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Sat, 21 Mar 2015 21:11:54 +0000 Subject: [PATCH] Refactored to match pinout structure --- description/overlay/display-o-tron.md | 9 ++++++ generate-html.py | 41 +++++++++++++++++++-------- overlay/display-o-tron.json | 34 ++++++++++++++++++++++ resources/pinout.css | 37 +++++++++++++++++++++++- resources/pinout.js | 2 +- template/layout.html | 15 ++++++---- 6 files changed, 118 insertions(+), 20 deletions(-) create mode 100644 description/overlay/display-o-tron.md create mode 100644 overlay/display-o-tron.json diff --git a/description/overlay/display-o-tron.md b/description/overlay/display-o-tron.md new file mode 100644 index 0000000..51ec802 --- /dev/null +++ b/description/overlay/display-o-tron.md @@ -0,0 +1,9 @@ +#Display-o-Tron 3000 + +You can use the one-line product installer to get Display-o-Tron 3000 set up and ready to go, just: + +```bash +curl get.pimoroni.com/dot3k | bash +``` + +And follow the instructions! \ No newline at end of file diff --git a/generate-html.py b/generate-html.py index 1a18606..e5199c7 100755 --- a/generate-html.py +++ b/generate-html.py @@ -4,11 +4,18 @@ import markdown import unicodedata import re import os +import time -resource_url = '/pinout2/resources/' -#resource_url = '/resources/' +base_url = '/pinout/' +resource_url = '/resources/' -overlays = ['pibrella','explorer-hat-pro','explorer-hat'] + +overlays = [ + 'pibrella', + 'explorer-hat-pro', + 'explorer-hat', + 'display-o-tron' + ] template = open('template/layout.html').read() @@ -18,6 +25,11 @@ select_overlays = {} overlays_html = '' +try: + os.mkdir('output/pinout') +except OSError: + pass + def slugify(value): """ Normalizes string, converts to lowercase, removes non-alpha characters, @@ -72,7 +84,7 @@ def load_md(filename): return html #return markdown.markdown(open(filename).read(), extensions=[gfm.HiddenHiliteExtension([]),'fenced_code']) except IOError: - return None + return '' def render_pin_text(pin_num, pin_url, pin_name, pin_subtext): return '

{}

{}{}
'.format(pin_url,pin_name,pin_subtext,load_md('description/pins/pin-{}.md'.format(pin_num))) @@ -163,16 +175,17 @@ def render_pin(pin_num, selected_url, overlay=None): #print(pin_type) - pin_url = slugify('pin{}_{}'.format(pin_num,pin_url)) + pin_url = base_url + slugify('pin{}_{}'.format(pin_num,pin_url)) #print(selected_url) selected = '' - if selected_url == pin_url: + + if base_url + selected_url == pin_url: selected = ' active' if pin_used: selected += ' overlay-pin' - return '
  • {} {}
  • \n'.format( + return '
  • {} {}
  • \n'.format( pin_num, ' '.join(map(slugify,pin_type)), selected, @@ -206,19 +219,19 @@ for url in select_overlays: overlays_html += ''.format(url, select_overlays[url]) -pages['index'] = render_overlay_page({'name':'Index','long_description':load_md('description/index.md')}) -navs['index'] = render_nav('index') +pages['pinout'] = render_overlay_page({'name':'Index','long_description':load_md('description/index.md')}) +navs['pinout'] = render_nav('pinout') print('Rendering pin pages...') for pin in range(1,len(pins)+1): (pin_url, pin_html) = render_pin_page(pin) pin_nav = render_nav(pin_url) - pin_html = template.replace('{{nav}}',pin_nav).replace('{{content}}',pin_html).replace('{{resource_url}}',resource_url).replace('{{overlays}}',overlays_html) + pin_html = template.replace('{{nav}}',pin_nav).replace('{{content}}',pin_html).replace('{{resource_url}}',resource_url).replace('{{overlays}}',overlays_html).replace('{{v}}',str(int(time.time()))) print('Outputting page {}'.format(pin_url)) - with open(os.path.join('output','{}.html'.format(pin_url)),'w') as f: + with open(os.path.join('output/pinout','{}.html'.format(pin_url)),'w') as f: f.write(pin_html) #nav = render_nav() @@ -229,7 +242,11 @@ for url in pages: content = pages[url] nav = navs[url] print('Outputting page {}'.format(url)) - html = template.replace('{{nav}}',nav).replace('{{content}}',content).replace('{{resource_url}}',resource_url).replace('{{overlays}}',overlays_html) + html = template.replace('{{nav}}',nav).replace('{{content}}',content).replace('{{resource_url}}',resource_url).replace('{{overlays}}',overlays_html).replace('{{v}}',str(int(time.time()))) + + if url != 'pinout': + url = os.path.join('pinout',url) + with open(os.path.join('output','{}.html'.format(url)),'w') as f: f.write(html) diff --git a/overlay/display-o-tron.json b/overlay/display-o-tron.json new file mode 100644 index 0000000..7ec5cfe --- /dev/null +++ b/overlay/display-o-tron.json @@ -0,0 +1,34 @@ +{ + "name": "Display-o-Tron 3000", + "manufacturer": "Pimoroni", + "url": "https://github.com/pimoroni/dot3k", + "description": "A 3-line character LCD with an RGB backlight and joystick", + "pincount": 40, + "pin": { + "7": { + "name": "Joystick Button", + "mode": "input", + "active": "low" + }, + "11": { + "name": "Joystick Left", + "mode": "input", + "active": "low" + }, + "13": { + "name": "Joystick Up", + "mode": "input", + "active": "low" + }, + "15": { + "name": "Joystick Right", + "mode": "input", + "active": "low" + }, + "21": { + "name": "Joystick Down", + "mode": "input", + "active": "low" + } + } +} diff --git a/resources/pinout.css b/resources/pinout.css index 705b48b..a8ec063 100644 --- a/resources/pinout.css +++ b/resources/pinout.css @@ -8,6 +8,37 @@ table td, table th {border:1px solid #073642;padding:5px;} table th {background:#073642;color:#EBE6D3;} table * {text-align:left;font-size:13px;} +.main-nav { + position:absolute; + right:0px; + top:0px; + margin:0; + padding:0; + list-style:none; +} +.main-nav li { + margin:0; + padding:0; + float:left; + border-right: 1px solid #666; + padding-right: 10px; +} + +.main-nav li:last-child { + border-right:none; + padding-right:0px; +} + + +.main-nav li a { + padding-left:10px; + color:#6D6D6D; + font-size:16px; +} +.main-nav li a:hover { + color:#D6264E; +} + nav#gpio { position:relative; width:300px; @@ -196,6 +227,9 @@ div#pinbasebplus { color:#888888; margin-bottom:5px; cursor:pointer; + position: absolute; + left:0px; + top:5px; } .logo img {float:left;position:relative;top:0px;margin:0 13px; -moz-transform:rotate(-45deg); @@ -228,11 +262,12 @@ h3 { margin:0 auto; margin-top:10px; position:relative; + padding-top:70px; } .overlay-container { position: absolute; right: 0px; - top: 65px; + top: 40px; } article a {color:#859900;text-decoration:underline;} article ul {margin-left:20px;margin-top:10px;margin-bottom:10px;} diff --git a/resources/pinout.js b/resources/pinout.js index 519a1c1..4840c04 100644 --- a/resources/pinout.js +++ b/resources/pinout.js @@ -26,7 +26,7 @@ jQuery(document).ready(function(){ $('.overlay').on('change',function(){ var url = $(this).val(); if( url != '' ){ - window.location.href = url + '.html' + window.location.href = '/pinout/' + url } }) diff --git a/template/layout.html b/template/layout.html index 0c0574a..0f6d619 100644 --- a/template/layout.html +++ b/template/layout.html @@ -5,7 +5,8 @@ - + +