commiting most recent changes

This commit is contained in:
Oliver Marks 2015-07-20 20:14:10 +01:00
parent cd01c72140
commit 83bd3c7ff7
14 changed files with 64 additions and 31 deletions

View File

@ -6,9 +6,13 @@ page_menu = [
('Contact', '#mailing-list-signup')]
banner_images = [
('/static/template/images/hackspace-banner.png', '', 'title', 'intro text'),
('/static/template/images/example-01.jpg', '', 'title', 'intro text'),
('/static/template/images/example-02.jpg', '', 'title', 'intro text')]
('/static/images/banners/hackspace-banner.png', '', '', ''),
('/static/images/banners/audio_board.jpg', 'Audio board', 'Audio board', ''),
('/static/images/banners/microscope.jpg', '', 'Microscope', ''),
('/static/images/banners/object_avoiding_robot.jpg', '', 'Object avoiding robot', ''),
('/static/images/banners/rocket_camera.jpg', 'Rocket Camera', 'Rocket Camera', '')]
#~ ('/static/template/images/example-01.jpg', '', 'title', 'intro text'),
#~ ('/static/template/images/example-02.jpg', '', 'title', 'intro text')]
tile_images = [
('/static/template/images/tile-01.jpg',),

File diff suppressed because one or more lines are too long

View File

@ -12,11 +12,11 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript" src="/static/js/jquery/jquery.min.js"></script>
</head>
<body>
<div id="headerstrip"><nav class="navstrip"><div class="left mini-logo">Maidstone Hackspace</div><div class="social"><div class="btn"><a href="https://twitter.com/share" class="twitter-share-button" data-via="MHackspace">Tweet</a></div><div class="btn"><div class="fb-share-button" data-href="http://maidstone-hackspace.org.uk/competition" data-layout="button_count"></div></div><div class="btn"><script type="IN/Share" data-url="http://maidstone-hackspace.org.uk/competition" data-counter="right"></script></div><div class="btn"><div size="standard" class="g-plusone" data-href="http://maidstone-hackspace.org.uk/competition" data-size="medium" data-annotation="bubble" count="true"></div></div></div></nav></div>
<div id="headerstrip"><nav class="navstrip"><div class="left mini-logo">Maidstone Hackspace</div><div class="social"><div class="btn"><a href="https://twitter.com/share" class="twitter-share-button" data-via="MHackspace">Tweet</a></div><div class="btn"><div class="fb-share-button" data-href="http://maidstone-hackspace.org.uk/" data-layout="button_count"></div></div><div class="btn"><script type="IN/Share" data-url="http://maidstone-hackspace.org.uk/" data-counter="right"></script></div><div class="btn"><div size="standard" class="g-plusone" data-href="http://maidstone-hackspace.org.uk/" data-size="medium" data-annotation="bubble" count="true"></div></div></div></nav></div>
<nav id="leftNav" class="menu" >
<ul>
<li class="mi0"><a href="/" >Home</a></li>
<li class="active mi1"><a href="/competition" >Competition</a></li>
<li class="active mi0"><a href="/" >Home</a></li>
<li class="mi1"><a href="/competition" >Competition</a></li>
<li class="mi2"><a href="/chat" >Chat</a></li>
<li class="mi3"><a href="#mailing-list-signup" >Contact</a></li>
</ul>

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,7 @@ import requests
import functools
import requests.exceptions
from lxml import etree
from lxml.html.clean import Cleaner
namespaces = {
@ -37,10 +38,12 @@ from email.utils import parsedate_tz, mktime_tz
class feed_reader:
"""parse a list of feeds and return details as dictionary data"""
#create the html cleaner, this is to clean out unwanted html tags in the description text
#page_structure=True,remove_unknown_tags=True
html_cleaner = Cleaner()
html_cleaner.javascript = True
html_cleaner.style = True
html_cleaner.remove_tags = ['script', 'iframe', 'link', 'style', 'img']
html_cleaner.remove_tags = ['script', 'iframe', 'link', 'style', 'img', 'div']
#~ html_cleaner.allow_tags = ['a', 'p', 'strong']
filter_by_date = datetime.datetime.now() - datetime.timedelta(days=int(1.5*365)) # 1 and a half years ago
@ -93,6 +96,27 @@ class feed_reader:
def clean_up_text(self, text):
"""strip out any dirty tags like <script> they may break the sites"""
cleaned_html = self.html_cleaner.clean_html(text)
# parse large text seperately
if len(text) > 600:
description = lxml.etree.parse(StringIO.StringIO(cleaned_html), self.html_parser)
root = description.getroot()
build = ''
for node in root[-1][-1].iter():
#skip any nodes with no text
if node.text is None and node.tail is None:
continue
# we may want to do some other node checks here
# perhaps count paragraphs, html layout changes a lot
if node.tag == 'br':
return build
else:
if node.tag == 'a' and node.text is None:
build += node.tail
else:
build += etree.tostring(node)
return self.html_cleaner.clean_html(text)
def fetch_image_from_node_text(self, text):
@ -124,6 +148,7 @@ class feed_reader:
# no image so lets fall back to the channel image if it exists
return self.channel_image
def fetch_node_text(self, node, name, default=''):
"""fetch the text from the node we are given, we are working in unicode
so decode byte strings to unicode"""
@ -172,7 +197,6 @@ class feed_reader:
def __iter__(self):
"""return results ordered by date"""
for order in sorted(self.results.keys(), reverse=True):
#print str(self.results[order]['date']) + ' - ' + self.results[order]['author'] + ' - ' + self.results[order]['title']
yield self.results[order]
if __name__ == "__main__":

View File

@ -37,7 +37,7 @@ with web.template as setup:
#~ <meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
#~ <meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
def header(title, description, url=''):
def header(title, description='Maidstone Hackspace is a shared space where artists, designers, makers, hackers, programmers, tinkerers, professionals and hobbyists can work on their projects', url=''):
# logo and social links at very top of the page
web.header_strip.create({})

View File

@ -7,7 +7,7 @@ from pages import header, footer
def index():
header()
header('Maidstone Hackspace Blog')
web.page.create('blogs')
web.columns.create()

View File

@ -8,7 +8,7 @@ from pages import header, footer
def index():
web.template.create('Maidstone Hackspace - Chat room')
header('chat')
header('Maidstone Hackspace Chat')
#web.template.body.append(web.header_strip.create({}).render())
#web.template.body.append(web.menu.render())
web.page.create(web.title.create('IRC Chat Room').render())

View File

@ -48,7 +48,7 @@ features = [
def index():
""" page for testing new components"""
web.template.create(title="Maidstone Hackspace - Screw sorting competition")
header('competition')
header('Maidstone Hackspace - Competition')
web.page.create(
web.images.create(

View File

@ -7,5 +7,5 @@ from pages import header, footer
def index():
header()
header('Maidstone Hackspace Forge')
return footer()

View File

@ -8,14 +8,16 @@ from pages import header, footer
def index():
web.template.create('Maidstone Hackspace')
header()
header('Maidstone Hackspace Homepage')
web.page.create('')
web.page.section(
web.images.create(
'/static/template/images/tile-01.jpg'
).append(
'/static/template/images/tile-01.jpg'
).set_classes('tile-right').render())
web.div.create(
web.images.create(
'/static/template/images/tile-01.jpg'
).append(
'/static/template/images/tile-01.jpg'
).render()
).set_classes('tile-right tile-image').render())
web.banner_slider.reset()
web.banner_slider * site.banner_images

View File

@ -48,7 +48,9 @@ label {margin-bottom:10px;float:left;clear:both;display:block;color:#fff;}
input {width:100%;margin:0px;margin-bottom:20px;padding:10px;}
button {margin-bottom:20px;background-color: #fff; height: 48px; width:100%; border-radius: 3px;box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.2);}
.tile-right {float:right;clear:right;}
.tile-right {margin-top:20px;width:230px;float:right;margin-right:20px;}
.tile-right img {float:right;}
.tile-image {float:right;clear:right;}
#headerstrip{position:absolute;left:0px;right:0px;height:68px;top:0px;background-color:#00232D;}
#headerstrip .navstrip{margin:10px;height:48px;}
#headerstrip .mini-logo{font-size:22px;padding-top: 12px;color:#fff;font-weight:bold;padding-left:58px;height:48px;background-image:url('/static/template/images/hackspace.png');background-repeat:no-repeat;}
@ -71,11 +73,11 @@ button {margin-bottom:20px;background-color: #fff; height: 48px; width:100%; bor
.google-groups-signup input{width:274px;}
.google-groups-signup a{color:#fff;}
.banner-slide {position:absolute;width:750px;}
.banner-slide ul{position:relative;overflow:hidden;width:750px;height:300px;margin:0px;}
.banner-slide {position:absolute;width:700px;margin:20px;}
.banner-slide ul{position:relative;overflow:hidden;width:700px;height:300px;margin:0px;}
.banner-slide li{position:absolute;left:0px;top:0px;list-style-type:none;padding:0px;margin:0px;}
.banner-slide .button{background-color: #0087A8;border-radius:50%;opacity: 0.4;}
.banner-slide .content{display:none;position:absolute;top:250px;width:100%;background-color: #eee;}
.banner-slide .button{background-color: #0087A8;border-radius:50%;opacity:0.4;}
.banner-slide .content{position:absolute;top:250px;width:100%;background-color: #eee;opacity: 0.4;}
.banner-slide .left{text-align:left;padding:6px;font-size:48px;color:#fff;position:absolute;top:122px;left:0px;width:60px;height:60px;background-color: transparent;}
.banner-slide .right{text-align:right;padding:6px;font-size:48px;color:#fff;position:absolute;top:122px;right:0px;width:60px;height:60px;background-color: transparent;}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

View File

@ -19,10 +19,11 @@ class control(www.default.html_ui):
self.content = []
def append(self, image, link, title, intro=''):
text = '<div class="content">%s<br />%s</div>' % (title, intro) if title else ''
if link:
self.content.append(u'<a href="%s" ><img src="%s" /><div class="content">%s<br />%s</div></a>' % (link, image, title, intro))
self.content.append(u'<a href="%s" ><img src="%s" />%s</a>' % (link, image, text))
else:
self.content.append(u'<img src="%s" /><div class="content">%s<br />%s</div>' % (image, title, intro))
self.content.append(u'<img src="%s" />%s' % (image, text))
def render(self):
self.count += 1