work on competition page, started adding a like widget

This commit is contained in:
Oliver Marks 2015-06-22 21:20:39 +01:00
parent f920b22742
commit 086cffdecb
13 changed files with 264 additions and 63 deletions

View File

@ -6,10 +6,13 @@ import argparse
from scaffold.web import web as html from scaffold.web import web as html
from scaffold.web import www from scaffold.web import www
from libs.rss_fetcher import feed_reader
import constants as site import constants as site
from pages import web from pages import web
from pages import header, footer from pages import header, footer
from pages import blog from pages import blog
from pages import competition
def examples(): def examples():
@ -25,39 +28,6 @@ def examples():
#finish of the page #finish of the page
return footer() return footer()
def competition():
""" page for testing new components"""
header()
web.page.create(
web.images.create(
image='/static/images/competitions/screw_sorting_competition_banner.jpg',
title="Screw sorting competition banner"
).add_attributes('align', 'middle'
).add_attributes('style', 'margin:auto;display:block;width:500px;'
).render())
web.paragraph.create(
"""We are some friendly competitions, so if your not sure what to work on consider entering and win some swag.""")
web.paragraph.append(
"""The First cometition will be to design a device which can sort a jar of screws by size, the winning entry we will attempt to build.""")
web.page.section(web.paragraph.render())
bullet_list = [
("Submit designs by some date here", ),
("Images can be design in any software or on a piece of paper but must be submitted as a jpg on the mailing list.", ),
("stick figures and crude line drawing are fine, we are not judge your artistic ability.",)]
web.list.create(ordered=False).set_classes('bullet-list')
web.list * bullet_list
web.page.section(web.list.render())
#render to the template
web.template.body.append(web.page.render())
#finish of the page
return footer()
def index(): def index():
header() header()
@ -108,19 +78,20 @@ def index():
web.page.append(web.twitter_feed.render()) web.page.append(web.twitter_feed.render())
#~ web.tiles.create() feed = feed_reader(site.rss_feeds)
#~ feed = feed_reader(site.rss_feeds)
#~ for row in feed: web.columns.create()
#~ print row.get('image') for row in feed:
#~ web.tiles.append( web.tiles.create()
#~ title = row.get('title'), web.columns.append(
#~ author = row.get('author'), web.tiles.append(
#~ link = row.get('url'), title = row.get('title'),
#~ image = row.get('image'), author = row.get('author'),
#~ date = row.get('date'), link = row.get('url'),
#~ description = row.get('description')) image = row.get('image'),
#~ web.div.append(row) date = row.get('date'),
#~ web.page.append(web.tiles.render()) description = row.get('description')).render())
web.page.append(web.columns.render())
web.template.body.append(web.page.render()) web.template.body.append(web.page.render())
@ -142,5 +113,5 @@ if __name__ == "__main__":
fp.write(blog.index().decode('utf-8')) fp.write(blog.index().decode('utf-8'))
with codecs.open('./html/competition.html', 'w', "utf-8") as fp: with codecs.open('./html/competition.html', 'w', "utf-8") as fp:
fp.write(competition().decode('utf-8')) fp.write(competition.index().decode('utf-8'))

File diff suppressed because one or more lines are too long

View File

@ -21,24 +21,79 @@
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-animate.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-animate.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script type="text/javascript" src="/static/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-animate.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script type="text/javascript" src="/static/js/jquery-2.1.4.min.js"></script> <script type="text/javascript" src="/static/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-animate.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-animate.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script type="text/javascript" src="/static/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-animate.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
</head> </head>
<body> <body>
<div id="headerstrip"><nav class="navstrip"><div class="left mini-logo">Maidstone Hackspace</div><div class="social"><div size="standard" class="g-plusone" data-href="http://maidstone-hackspace.org.uk/" data-size="medium" data-annotation="inline" count="true"></div></div></nav></div> <div id="headerstrip"><nav class="navstrip"><div class="left mini-logo">Maidstone Hackspace</div><div class="social"><div size="standard" class="g-plusone" data-href="http://maidstone-hackspace.org.uk/" data-size="medium" data-annotation="inline" count="true"></div><a href="https://twitter.com/share" class="twitter-share-button" data-via="True">Tweet</a><div size="standard" class="g-plusone" data-size="medium" data-annotation="inline" count="true"></div></div></nav></div>
<nav id="leftNav" class="menu" ><ul><li class="active mi0"><a href="/" >Home</a></li><li class="mi1"><a href="#mailing-list-signup" >Contact</a></li></ul><div style="clear:both;"></div></nav> <nav id="leftNav" class="menu" ><ul><li class="active mi0"><a href="/" >Home</a></li><li class="mi1"><a href="#mailing-list-signup" >Contact</a></li></ul><div style="clear:both;"></div></nav>
<div class="page" ><header class="pageHeader"><img src="/static/images/competitions/screw_sorting_competition_banner.jpg" alt="Screw sorting competition banner" align="middle" style="margin:auto;display:block;width:500px;" /></header><section class="pageSection"><p>We are some friendly competitions, so if your not sure what to work on consider entering and win some swag.The First cometition will be to design a device which can sort a jar of screws by size, the winning entry we will attempt to build.</p></section><section class="pageSection"><ul class="bullet-list" > <div class="page" ><header class="pageHeader"><img src="/static/images/competitions/screw_sorting_competition_banner.jpg" alt="Screw sorting competition banner" align="middle" style="margin:auto;display:block;width:500px;" /></header><section class="pageSection"><p>Welcome to the first ever maidstone hackspace competition, we are a new hackspace, so we are looking to get the word out and get some collaberation going.The First cometition will be to design a device which can sort a jar of screws by size, the winning entry we will attempt to build.</p></section><section class="pageSection"><ul class="bullet-list" >
<li>Submit designs by some date here</li> <li>Submit designs by some date here</li>
<li>Images can be design in any software or on a piece of paper but must be submitted as a jpg on the mailing list.</li> <li>Images can be design in any software or drawn on a piece of paper but must be submitted as a jpg on the mailing list.</li>
<li>stick figures and crude line drawing are fine, we are not judge your artistic ability.</li> <li>Stick figures and crude line drawing are fine, we are not judge your artistic ability.</li>
</ul></section><footer class="pageFooter"></footer></div> </ul></section><section class="pageSection"><h2>Win a UNO Basic Starter Kit</h2></section><section class="pageSection"><p><img src="http://imgapp.banggood.com/thumb/large/2014/xiemeijuan/03/SKU208787/SKU208787a.jpg" alt="Arduino starter kit" align="middle" style="margin:auto;display:block;width:500px;" />This kit comes with an arduino board and various sensors and components, list below of every thing in the kit.<ul class="bullet-list" >
<li>1 x Arduino UNO R3 development board</li>
<li>1 x USB cable</li>
<li>1 x Prototype extension board</li>
<li>1 x Mini breadboard</li>
<li>1 x 5V stepper motor</li>
<li>1 x 2003 stepper motor driver board</li>
<li>5 x Red LED</li>
<li>5 x Green LED</li>
<li>5 x Yellow LED</li>
<li>2 x Vibration Sensor</li>
<li>1 x Flame sensor</li>
<li>1 x LM35 temperature sensor</li>
<li>1 x Infrared receiver</li>
<li>3 x Photoresistor</li>
<li>4 x Key cap</li>
<li>4 x Key switch</li>
<li>1 x Adjustable potentiometer</li>
<li>1 x Passive buzzer</li>
<li>1 x Active buzzer</li>
<li>1 x Jumper cap</li>
<li>1 x Large breadboard</li>
<li>1 x Remote Control</li>
<li>1 x 1602 Screen</li>
<li>1 x 9G servos</li>
<li>1 x Component box</li>
<li>1 x 10p DuPont line</li>
<li>30 x Breadboard line(approximately)</li>
<li>1 x 220ohm resistance</li>
<li>1 x 8*8 dot matrix</li>
<li>1 x One digit eight segment tube</li>
<li>1 x Four digit eight segment tube</li>
<li>1 x IC 74HC595</li>
<li>1 x Battery Holder</li>
<li>1 x 1K resistor plug</li>
<li>1 x 10K resistor plug</li>
<li>1 x 9V battery</li>
<li>1 x 2.54mm 40pin pin header</li>
</ul></p></section><footer class="pageFooter"></footer></div>
<div id="footer"><div id="footertop"></div><div id="footerbottom"><div class="container"><div class="copyright">&copy;2015 Maidstone Hackspace</div><div id="mailing-list-signup" class="google-groups-signup"><h3>Signup and make yourself known</h3><form class="block" name="signup" method="get" action="http://groups.google.com/group/maidstone-hackspace/boxsubscribe"><label for="groups-email">Email Address</label><input id="groups-email" name="email" class="required"/><button type="submit" />Subscribe</button><a href="http://groups.google.com/group/maidstone-hackspace">Browse Archives</a></form><div style="clear:both;"></div><div></div></div><div> <div id="footer"><div id="footertop"></div><div id="footerbottom"><div class="container"><div class="copyright">&copy;2015 Maidstone Hackspace</div><div id="mailing-list-signup" class="google-groups-signup"><h3>Signup and make yourself known</h3><form class="block" name="signup" method="get" action="http://groups.google.com/group/maidstone-hackspace/boxsubscribe"><label for="groups-email">Email Address</label><input id="groups-email" name="email" class="required"/><button type="submit" />Subscribe</button><a href="http://groups.google.com/group/maidstone-hackspace">Browse Archives</a></form><div style="clear:both;"></div><div></div></div><div>
<link rel="icon" type="image/png" href="/static/images/favicon.png">
<link rel="stylesheet" id="navigationCss" href="/static/template/default.css" media="" type="text/css" />
<link rel="stylesheet" id="navigationCss" href="/static/template/js/jquery-ui/themes/base/jquery-ui.css" media="" type="text/css" />
<link rel="icon" type="image/png" href="/static/images/favicon.png">
<link rel="stylesheet" id="navigationCss" href="/static/template/default.css" media="" type="text/css" />
<link rel="stylesheet" id="navigationCss" href="/static/template/js/jquery-ui/themes/base/jquery-ui.css" media="" type="text/css" />
<link rel="icon" type="image/png" href="/static/images/favicon.png">
<link rel="stylesheet" id="navigationCss" href="/static/template/default.css" media="" type="text/css" />
<link rel="stylesheet" id="navigationCss" href="/static/template/js/jquery-ui/themes/base/jquery-ui.css" media="" type="text/css" />
<script type="text/javascript" ><!--//--><![CDATA[//><!-- <script type="text/javascript" ><!--//--><![CDATA[//><!--
//twitter code //twitter code
!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"); !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");

View File

@ -10,12 +10,13 @@
<script type="text/javascript" src="/static/js/jquery-2.1.4.min.js"></script> <script type="text/javascript" src="/static/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-animate.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular-animate.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><title>Maidstone Hackspace</title> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><title>Maidstone Hackspace</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta property="description" name="description" content="Hackspace for Maidstone, kent. for collaberation and discussion for artists, designers, makers, hackers, programmers, tinkerer, professionals and hobbyists." /> <meta property="description" name="description" content="Hackspace for Maidstone, kent. for collaberation and discussion for artists, designers, makers, hackers, programmers, tinkerer, professionals and hobbyists." />
</head> </head>
<body> <body>
<div id="headerstrip"><nav class="navstrip"><div class="left mini-logo">Maidstone Hackspace</div><div class="social"><div size="standard" class="g-plusone" data-href="http://maidstone-hackspace.org.uk/" data-size="medium" data-annotation="inline" count="true"></div></div></nav></div> <div id="headerstrip"><nav class="navstrip"><div class="left mini-logo">Maidstone Hackspace</div><div class="social"><div size="standard" class="g-plusone" data-href="http://maidstone-hackspace.org.uk/" data-size="medium" data-annotation="inline" count="true"></div><a href="https://twitter.com/share" class="twitter-share-button" data-via="True">Tweet</a><div size="standard" class="g-plusone" data-size="medium" data-annotation="inline" count="true"></div></div></nav></div>
<nav id="leftNav" class="menu" ><ul><li class="active mi0"><a href="/" >Home</a></li><li class="mi1"><a href="#mailing-list-signup" >Contact</a></li></ul><div style="clear:both;"></div></nav> <nav id="leftNav" class="menu" ><ul><li class="active mi0"><a href="/" >Home</a></li><li class="mi1"><a href="#mailing-list-signup" >Contact</a></li></ul><div style="clear:both;"></div></nav>
<div id="headerstrip"><nav class="navstrip"><div class="left mini-logo">Maidstone Hackspace</div><div class="social"></div></nav></div> <div id="headerstrip"><nav class="navstrip"><div class="left mini-logo">Maidstone Hackspace</div><div class="social"></div></nav></div>
<nav id="leftNav" class="menu" ><ul><li class="active mi0"><a href="/" >Home</a></li><li class="mi1"><a href="#mailing-list-signup" >Contact</a></li></ul><div style="clear:both;"></div></nav> <nav id="leftNav" class="menu" ><ul><li class="active mi0"><a href="/" >Home</a></li><li class="mi1"><a href="#mailing-list-signup" >Contact</a></li></ul><div style="clear:both;"></div></nav>
@ -34,6 +35,10 @@
</a> </a>
</div></section><footer class="pageFooter"></footer></div> </div></section><footer class="pageFooter"></footer></div>
<div id="footer"><div id="footertop"></div><div id="footerbottom"><div class="container"><div class="copyright">&copy;2015 Maidstone Hackspace</div><div id="mailing-list-signup" class="google-groups-signup"><h3>Signup and make yourself known</h3><form class="block" name="signup" method="get" action="http://groups.google.com/group/maidstone-hackspace/boxsubscribe"><label for="groups-email">Email Address</label><input id="groups-email" name="email" class="required"/><button type="submit" />Subscribe</button><a href="http://groups.google.com/group/maidstone-hackspace">Browse Archives</a></form><div style="clear:both;"></div><div></div></div><div> <div id="footer"><div id="footertop"></div><div id="footerbottom"><div class="container"><div class="copyright">&copy;2015 Maidstone Hackspace</div><div id="mailing-list-signup" class="google-groups-signup"><h3>Signup and make yourself known</h3><form class="block" name="signup" method="get" action="http://groups.google.com/group/maidstone-hackspace/boxsubscribe"><label for="groups-email">Email Address</label><input id="groups-email" name="email" class="required"/><button type="submit" />Subscribe</button><a href="http://groups.google.com/group/maidstone-hackspace">Browse Archives</a></form><div style="clear:both;"></div><div></div></div><div>
<link rel="icon" type="image/png" href="/static/images/favicon.png">
<link rel="stylesheet" id="navigationCss" href="/static/template/default.css" media="" type="text/css" />
<link rel="stylesheet" id="navigationCss" href="/static/template/js/jquery-ui/themes/base/jquery-ui.css" media="" type="text/css" />
<script type="text/javascript" ><!--//--><![CDATA[//><!-- <script type="text/javascript" ><!--//--><![CDATA[//><!--
//twitter code //twitter code
!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"); !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");

View File

@ -7,6 +7,7 @@ from flask import make_response
import generate import generate
from pages import blog from pages import blog
from pages import competition
web_app = Flask(__name__, static_url_path='/static') web_app = Flask(__name__, static_url_path='/static')
@ -29,9 +30,9 @@ def index():
return make_response(generate.index()) return make_response(generate.index())
@web_app.route("/competition/", methods=['GET']) @web_app.route("/competition/", methods=['GET'])
def competition(): def competition_index():
"""competition page""" """competition page"""
return make_response(generate.competition()) return make_response(competition.index())
if __name__ == '__main__': if __name__ == '__main__':
web_app.run(host='0.0.0.0', port=5000, debug=True) web_app.run(host='0.0.0.0', port=5000, debug=True)

View File

@ -26,7 +26,10 @@ web.template.css_includes.append('/static/template/js/jquery-ui/themes/base/jque
def header(): def header():
# logo and social links at very top of the page # logo and social links at very top of the page
web.header_strip.create({}) web.header_strip.create({})
web.header_strip.social(web.google_plus.create(web.template.domain, plus=True, share=False, comments=False).render()) web.header_strip.social(web.google_plus.create(web.template.domain, plus=True, share=False, comments=False).render())
web.header_strip.social(web.like.create(url=web.template.domain, plus=True, twitter='MHackspace').render())
web.template.body.append(web.header_strip.render()) web.template.body.append(web.header_strip.render())
# navigation # navigation

Binary file not shown.

97
site/pages/competition.py Normal file
View File

@ -0,0 +1,97 @@
import constants as site
from libs.rss_fetcher import feed_reader
from pages import web
from pages import header, footer
features = [
('1 x Arduino UNO R3 development board',),
('1 x USB cable',),
('1 x Prototype extension board',),
('1 x Mini breadboard',),
('1 x 5V stepper motor',),
('1 x 2003 stepper motor driver board',),
('5 x Red LED',),
('5 x Green LED',),
('5 x Yellow LED',),
('2 x Vibration Sensor',),
('1 x Flame sensor',),
('1 x LM35 temperature sensor',),
('1 x Infrared receiver',),
('3 x Photoresistor',),
('4 x Key cap',),
('4 x Key switch',),
('1 x Adjustable potentiometer',),
('1 x Passive buzzer',),
('1 x Active buzzer',),
('1 x Jumper cap',),
('1 x Large breadboard',),
('1 x Remote Control',),
('1 x 1602 Screen',),
('1 x 9G servos',),
('1 x Component box',),
('1 x 10p DuPont line',),
('30 x Breadboard line(approximately)',),
('1 x 220ohm resistance',),
('1 x 8*8 dot matrix',),
('1 x One digit eight segment tube',),
('1 x Four digit eight segment tube',),
('1 x IC 74HC595',),
('1 x Battery Holder',),
('1 x 1K resistor plug',),
('1 x 10K resistor plug',),
('1 x 9V battery',),
('1 x 2.54mm 40pin pin header',)]
def index():
""" page for testing new components"""
header()
web.page.create(
web.images.create(
image='/static/images/competitions/screw_sorting_competition_banner.jpg',
title="Screw sorting competition banner"
).add_attributes('align', 'middle'
).add_attributes('style', 'margin:auto;display:block;width:500px;'
).render())
web.paragraph.create(
"""Welcome to the first ever maidstone hackspace competition, we are a new hackspace, so we are looking to get the word out and get some collaberation going.""")
web.paragraph.append(
"""The First cometition will be to design a device which can sort a jar of screws by size, the winning entry we will attempt to build.""")
web.page.section(web.paragraph.render())
bullet_list = [
("Submit designs by some date here", ),
("Images can be design in any software or drawn on a piece of paper but must be submitted as a jpg on the mailing list.", ),
("Stick figures and crude line drawing are fine, we are not judge your artistic ability.",)]
web.list.create(ordered=False).set_classes('bullet-list')
web.list * bullet_list
web.page.section(web.list.render())
web.page.section(web.title.create('Win a UNO Basic Starter Kit', 2).render())
web.paragraph.create(
web.images.create(
image='http://imgapp.banggood.com/thumb/large/2014/xiemeijuan/03/SKU208787/SKU208787a.jpg',
title="Arduino starter kit"
).add_attributes('align', 'middle'
).add_attributes('style', 'margin:auto;display:block;width:500px;'
).render())
web.paragraph.append(
"""This kit comes with an arduino board and various sensors and components, list below of every thing in the kit.""")
web.list.create(ordered=False).set_classes('bullet-list')
web.list * features
web.paragraph.append(
web.list.render())
web.page.section(web.paragraph.render())
#render to the template
web.template.body.append(web.page.render())
#finish of the page
return footer()

View File

@ -8,5 +8,4 @@ from pages import header, footer
def index(): def index():
header() header()
return footer() return footer()

View File

@ -116,7 +116,7 @@ button {margin-bottom:20px;background-color: #fff; height: 48px; width:100%; bor
left:0px;opacity:1; left:0px;opacity:1;
} }
.bullet-list li {margin:10px;} .bullet-list li {margin:0px;margin-left:10px;line-height:100%;}
.tile {position:relative;background-color:#eee;width:460px;margin-left:20px;margin-bottom:20px;float:left;box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.26);} .tile {position:relative;background-color:#eee;width:460px;margin-left:20px;margin-bottom:20px;float:left;box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.26);}
.tile-img {margin:20px;width:420px;height:200px;overflow:hidden;background-repeat: no-repeat;background-position: center;background-image:url('/static/template/images/background.png');} .tile-img {margin:20px;width:420px;height:200px;overflow:hidden;background-repeat: no-repeat;background-position: center;background-image:url('/static/template/images/background.png');}

58
site/widgets/like.py Normal file
View File

@ -0,0 +1,58 @@
from scaffold.core.widget import base_widget
class control(base_widget):
link = None
action = ""
includes = []
script = []
facebook = False
twitter = True
plus = True
plus_script = False
linkedin_script = False
facebook_script = False
twitter_script = False
size = 'medium'
annotation = 'inline'
def create(self, url, plus=None, twitter=None, facebook=None, linkedin=None):
self.plus = plus
if plus:
if self.plus_script is False:
self.plus_script = True
self.includes.append('<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>')
if twitter:
if self.twitter_script is False:
self.twitter_script = True
self.footer.append("""
<script>!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');</script>""")
if facebook:
if self.facebook_script is False:
self.facebook_script = True
self.footer.append("""
<div id="fb-root"></div><script>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.3";fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script>""")
return self
def url(self, link=None):
self.link = link
return self
def render(self):
link = ''
self.count += 1
htm = ''
if self.twitter:
htm += '<a href="https://twitter.com/share" class="twitter-share-button" data-via="%s">Tweet</a>' % self.twitter
if self.facebook:
htm += '<div class="fb-like" data-href="%s" data-layout="button_count" data-action="like" data-show-faces="true" data-share="true"></div>' % self.url
if self.link:
link = ' data-href="' + self.link + '" '
if self.plus is True:
htm += '<div size="standard" class="g-plusone" ' + link + self.action + ' data-size="' + self.size + '" data-annotation="' + self.annotation + '" count="true"></div>'
return htm

View File

@ -1,6 +1,6 @@
from scaffold.web import www from scaffold.core.widget import base_widget
class control(www.default.html_ui): class control(base_widget):
"""rss feed widgets""" """rss feed widgets"""
def create(self): def create(self):
self.data = [] self.data = []
@ -14,6 +14,7 @@ class control(www.default.html_ui):
'link': link, 'link': link,
'image': image, 'image': image,
'description': description}) 'description': description})
return self
def render(self): def render(self):
htm = u'' htm = u''

Binary file not shown.