adding rss feeds to the site, work in progress
|
@ -11,3 +11,7 @@ banner_images = [
|
|||
tile_images = [
|
||||
('/static/template/images/tile-01.jpg',),
|
||||
('/static/template/images/tile-02.jpg',)]
|
||||
|
||||
rss_feed = [
|
||||
('/static/template/images/background.png', 'http://waistcoatforensicator.blogspot.com/feeds/posts/default?alt=rss'), # simon ridley
|
||||
]
|
||||
|
|
|
@ -13,6 +13,8 @@ from scaffold.web import www
|
|||
|
||||
import constants as site
|
||||
|
||||
from libs.rss_fetcher import feed_reader
|
||||
|
||||
web = html()
|
||||
web.load_widgets('widgets')
|
||||
web.template.create('Maidstone Hackspace', 'Hackspace for Maidstone, kent. for collaberation and discussion for artists, designers, makers, hackers, programmers, tinkerer, professionals and hobbyists.')
|
||||
|
@ -27,7 +29,6 @@ image_path = domain + os.sep + 'template' + os.sep + 'images' + os.sep
|
|||
web.template.css_includes.append('/static/template/default.css')
|
||||
web.template.css_includes.append('/static/template/js/jquery-ui/themes/base/jquery-ui.css')
|
||||
#~ web.template.javascript_includes.append('/static/template/js/jquery-ui/themes/base/jquery-ui.css')
|
||||
web.template.javascript_includes.append('<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>')
|
||||
|
||||
def todict(data):
|
||||
new_dict = {}
|
||||
|
@ -38,27 +39,27 @@ def todict(data):
|
|||
def dict_to_list(data, keys):
|
||||
return [data.get(k) for k in keys]
|
||||
|
||||
class feed_reader:
|
||||
def __init__(self, url):
|
||||
#~ class feed_reader:
|
||||
#~ def __init__(self, url):
|
||||
#~ self.feed = requests.get(url, stream=True)
|
||||
fp = open('rss_example.xml', 'r')
|
||||
self.feed = etree.parse(fp)
|
||||
self.feed = self.feed.getroot()
|
||||
|
||||
self.title = self.feed.xpath('./channel/title/text()')[-1]
|
||||
self.link = self.feed.xpath('./channel/link/text()')[-1]
|
||||
self.description = self.feed.xpath('./channel/description/text()')[-1]
|
||||
|
||||
self.channel_image = self.feed.xpath('.//image/url/text()')[-1]
|
||||
self.channel_image_title = self.feed.xpath('.//image/title/text()')[-1]
|
||||
self.channel_image_link = self.feed.xpath('.//image/link/text()')[-1]
|
||||
|
||||
def __iter__(self):
|
||||
for item in self.feed.xpath('.//item'):
|
||||
title = item.xpath('./title/text()')
|
||||
link = item.xpath('./link/text()')
|
||||
description = item.xpath('./description/text()')
|
||||
yield title, link, description
|
||||
#~ fp = open('rss_example.xml', 'r')
|
||||
#~ self.feed = etree.parse(fp)
|
||||
#~ self.feed = self.feed.getroot()
|
||||
#~
|
||||
#~ self.title = self.feed.xpath('./channel/title/text()')[-1]
|
||||
#~ self.link = self.feed.xpath('./channel/link/text()')[-1]
|
||||
#~ self.description = self.feed.xpath('./channel/description/text()')[-1]
|
||||
#~
|
||||
#~ self.channel_image = self.feed.xpath('.//image/url/text()')[-1]
|
||||
#~ self.channel_image_title = self.feed.xpath('.//image/title/text()')[-1]
|
||||
#~ self.channel_image_link = self.feed.xpath('.//image/link/text()')[-1]
|
||||
#~
|
||||
#~ def __iter__(self):
|
||||
#~ for item in self.feed.xpath('.//item'):
|
||||
#~ title = item.xpath('./title/text()')
|
||||
#~ link = item.xpath('./link/text()')
|
||||
#~ description = item.xpath('./description/text()')
|
||||
#~ yield title, link, description
|
||||
|
||||
#~ class page:
|
||||
#~ def __enter__(self):
|
||||
|
@ -72,6 +73,10 @@ def header():
|
|||
web.menu * site.page_menu
|
||||
web.template.body.append(web.header_strip.create({}).render())
|
||||
web.template.body.append(web.menu.render())
|
||||
web.template.javascript_includes.append('<script type="text/javascript" src="/static/js/jquery-2.1.4.min.js"></script>')
|
||||
web.template.javascript_includes.append('<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>')
|
||||
web.template.javascript_includes.append('<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-animate.js"></script>')
|
||||
|
||||
|
||||
def footer():
|
||||
web.footer_content.create().append(
|
||||
|
@ -85,7 +90,7 @@ def examples():
|
|||
""" page for testing new components"""
|
||||
header()
|
||||
web.page.create('examples')
|
||||
web.twitter_feed.create('olymk2')
|
||||
web.twitter_feed.create(username='MHackspace', widget_id='606798560374484992')
|
||||
web.page.section(web.twitter_feed.render())
|
||||
|
||||
web.page.append(
|
||||
|
@ -95,13 +100,19 @@ def examples():
|
|||
)
|
||||
|
||||
web.tiles.create()
|
||||
feed = feed_reader('')
|
||||
#~ feed = feed_reader('')
|
||||
|
||||
feed_url = 'http://waistcoatforensicator.blogspot.com/feeds/posts/default?alt=rss'
|
||||
|
||||
feed = feed_reader(feed_url)
|
||||
|
||||
for row in feed:
|
||||
print row
|
||||
web.tiles.append(
|
||||
title = feed.title,
|
||||
link = feed.link,
|
||||
image = feed.channel_image,
|
||||
description = 'lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum.')
|
||||
title = '%s By %s' %(row.get('title'), row.get('author')),
|
||||
link = row.get('link'),
|
||||
image = row.get('image'),
|
||||
description = row.get('description'))
|
||||
web.div.append(str(row))
|
||||
web.page.append(web.tiles.render())
|
||||
|
||||
|
@ -111,8 +122,8 @@ def examples():
|
|||
def index():
|
||||
header()
|
||||
|
||||
web.menu.create('/', 'leftNav')
|
||||
web.menu * site.page_menu
|
||||
#~ web.menu.create('/', 'leftNav')
|
||||
#~ web.menu * site.page_menu
|
||||
|
||||
web.template.body.append(web.header_strip.create({}).render())
|
||||
web.template.body.append(web.menu.render())
|
||||
|
@ -157,6 +168,7 @@ def index():
|
|||
|
||||
web.div.create('').set_classes('panel')
|
||||
|
||||
web.twitter_feed.create(username='MHackspace', widget_id='606798560374484992')
|
||||
web.page.append(web.twitter_feed.render())
|
||||
web.template.body.append(web.page.render())
|
||||
|
||||
|
@ -168,5 +180,8 @@ if __name__ == "__main__":
|
|||
#~ args = parser.parse_args()
|
||||
#~ print(args.accumulate(args.integers))
|
||||
|
||||
index()
|
||||
examples()
|
||||
with open('index.html', 'w') as fp:
|
||||
fp.write(index())
|
||||
with open('examples.html', 'w') as fp:
|
||||
fp.write(examples())
|
||||
|
||||
|
|
|
@ -19,3 +19,6 @@ def index():
|
|||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5000, debug=True)
|
||||
|
||||
|
||||
#http://waistcoatforensicator.blogspot.com/feeds/posts/default?alt=rss
|
||||
|
|
|
@ -75,12 +75,25 @@ button {margin-bottom:20px;background-color: #fff; height: 48px; width:100%; bor
|
|||
.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;}
|
||||
|
||||
/*slider animation*/
|
||||
.slide {position:absolute;left:0px;}
|
||||
|
||||
.slide.ng-hide-add {left:0px;opacity:1;}
|
||||
.slide.ng-hide-add-active {transition:0.9s linear all;opacity:0;}
|
||||
|
||||
.slide.ng-hide-remove {left:0px;opacity:0;}
|
||||
.slide.ng-hide-remove-active {transition:0.9s linear all;opacity:1;}
|
||||
|
||||
}
|
||||
|
||||
.bullet-list li {margin:10px;}
|
||||
|
||||
.tile {background-color:#eee;width:300px;height:350px;margin:10px;float:left;box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.26);}
|
||||
.tile img{width:300px;height:200px;}
|
||||
.tile {position:relative;background-color:#eee;width:460px;height:640px;margin-left:20px;margin-bottom:20px;float:left;box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.26);}
|
||||
.tile-img {width:100%;height:200px;overflow:hidden;background-repeat: no-repeat;background-position: center;background-image:url('/static/template/images/background.png');}
|
||||
.tile-content {position:absolute;bottom:20px;top:220px;overflow:scroll;left:20px;right:20px;text-align:justify;line-height:150%;font-size:12px;}
|
||||
.tile img {display:block;margin:auto;width:300px;height:200px;}
|
||||
|
||||
#footertop {background-color:#00232D;height:48px;}
|
||||
#footerbottom {background-color:#0087A8;height:300px;}
|
||||
#footerbottom div.container {margin:auto;background-color:#0087A8;height:250px;width:960px;}
|
||||
.twitter-feed {width:460px;margin:10px;}
|
||||
.twitter-feed {width:460px;margin:20px;}
|
||||
|
|
After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 94 KiB |
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
from scaffold.web import www
|
||||
|
||||
class control(www.default.html_ui):
|
||||
|
@ -10,9 +11,12 @@ class control(www.default.html_ui):
|
|||
height=300
|
||||
width=400
|
||||
|
||||
def javascript(self):
|
||||
js=("",)
|
||||
return "\n".join(js)
|
||||
with open(os.path.abspath('./widgets/banner_slider.js')) as fp:
|
||||
script = [fp.read()]
|
||||
|
||||
#~ def javascript(self):
|
||||
#~ return fp.read()
|
||||
#~ self.script.append()
|
||||
|
||||
def create(self):
|
||||
self.reset()
|
||||
|
@ -27,14 +31,16 @@ class control(www.default.html_ui):
|
|||
self.content.append(htm)
|
||||
|
||||
def render(self):
|
||||
#~ self.script.append(self.javascript())
|
||||
self.count+=1
|
||||
htm='<div class="banner-slide">'
|
||||
htm+='<ul style="%s">' % self.height
|
||||
htm='<div class="banner-slide" ng-app="myApp" ng-controller="sliderController">'
|
||||
htm+='<ul style="%s" >' % self.height
|
||||
count=0
|
||||
for item in self.content:
|
||||
htm+='<li>%s</li>' % (item)
|
||||
count+=1
|
||||
htm+='<li style="clear:both;"></li></ul>'
|
||||
htm+='<div title="Previous" class="left"><</div><div title="Next" class="right">></div>'
|
||||
htm+='</div><div class="clear"></div>'
|
||||
#~ for item in self.content:
|
||||
#~ htm+='<li class="slide" ng-hide="!isCurrentSlideIndex($index)">%s</li>' % (item)
|
||||
#~ count+=1
|
||||
htm += '''<li class="slide" ng-repeat="slide in slides" ng-hide="!isCurrentSlideIndex($index)" ng-show="isCurrentSlideIndex($index)"><a href="{{slide.link}}" ><img src="{{slide.src}}" /><div class="content">{{slide.title}}<br />{{slide.description}}</div></a></li>'''
|
||||
htm += '<li style="clear:both;"></li></ul>'
|
||||
htm += '<div ng-click="prev()" title="Previous" class="left"><</div><div ng-click="next()" title="Next" class="right">></div>'
|
||||
htm += '</div><div class="clear"></div>'
|
||||
return htm
|
||||
|
|
|
@ -8,10 +8,10 @@ class control(www.default.html_ui):
|
|||
|
||||
def render(self):
|
||||
htm = '<div %s class="google-groups-signup"><h3>Signup %s</h3>' % (self.node_id, self.title)
|
||||
htm += '<form class="block" action="http://groups.google.com/group/%s/boxsubscribe">' % self.name
|
||||
htm += '<form class="block" name="signup" method="get" action="http://groups.google.com/group/%s/boxsubscribe">' % self.name
|
||||
htm += '<label for="groups-email">Email Address</label>'
|
||||
htm += '<input id="groups-email" name="email" class="required"/>'
|
||||
htm += '<button type="submit" />Subscribe</button>'
|
||||
htm += '<button type="submit" />Subscribe</button>'
|
||||
htm += '<a href="http://groups.google.com/group/%s">Browse Archives</a>' % self.name
|
||||
htm += '</form><div style="clear:both;"></div><div>'
|
||||
return htm
|
||||
|
|
|
@ -13,7 +13,7 @@ class control(www.default.html_ui):
|
|||
htm = ''
|
||||
for project in self.data:
|
||||
htm+='<div class="tile">'
|
||||
htm+='<div><img src="%s"/></div>' % project[2]
|
||||
htm+='<div><a href="%s">%s</a><p>%s</p></div>' % (project[1], project[0], project[3])
|
||||
htm+='<div class="tile-img"><img src="%s"/></div>' % project[2]
|
||||
htm+='<div class="tile-content"><a href="%s">%s</a><p>%s</p></div>' % (project[1], project[0], project[3])
|
||||
htm+='</div>'
|
||||
return htm
|
||||
|
|
|
@ -5,9 +5,10 @@ class control(www.default.html_ui):
|
|||
https://dev.twitter.com/web/embedded-timelines#customization"""
|
||||
script = ["""//twitter code\n!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");\n"""]
|
||||
|
||||
def create(self, name=""):
|
||||
def create(self, username, widget_id):
|
||||
self.reset()
|
||||
self.name = name
|
||||
self.username = username
|
||||
self.widget_id = widget_id
|
||||
return self
|
||||
|
||||
def set_size(self, width, height):
|
||||
|
@ -19,9 +20,9 @@ class control(www.default.html_ui):
|
|||
self.count += 1
|
||||
htm = '''
|
||||
<div class="twitter-feed">
|
||||
<a class="twitter-timeline" href="https://twitter.com/%s" data-widget-id="603654160072974336">
|
||||
<a class="twitter-timeline" href="https://twitter.com/%s" data-widget-id="%s">
|
||||
Tweets by @%s
|
||||
</a>
|
||||
</div>''' % (
|
||||
self.name, self.name)
|
||||
self.username, self.widget_id, self.username)
|
||||
return htm
|
||||
|
|