Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

First commit. Export from svn.

  • Loading branch information...
commit 5445bf29a8a92433bdb4ed39d4d459b1ff45c4b7 0 parents
Usware Technologies authored
21 README.txt
@@ -0,0 +1,21 @@
+ABOUT
+-----------
+This is an app to show the latest buzz around a topic. It uses the latest shares from google reader to find out what is hot.
+
+LICENCE:
+--------
+The following code is released under a GNU GPL v2.0 license. (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
+
+
+READ THE FOLLOWING BEFORE USING THE CODE
+----------------------------------------
+1)fetchfeed.py is the cron job which fetches data from the friendfeed API for every 10 minutes.
+ Please setup fetchfeed.py as cronjob using crontab.
+2)Please change the values in localsettings.py as per your local settings.
+
+
+SUBMITTING A PATCH
+------------------
+If want to submit a patch after fixing some bugs or adding new functionality.Please email your patch to github@uswaretech.com.
+
+Feel free to reuse this app in your own application.
0  __init__.py
No changes.
7 doloto.kpf
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Komodo Project File - DO NOT EDIT -->
+<project id="2b3a78a6-b86e-4c65-9332-eaf35c73994b" kpf_version="4" name="doloto.kpf">
+<preference-set idref="2b3a78a6-b86e-4c65-9332-eaf35c73994b">
+ <boolean id="import_live">1</boolean>
+</preference-set>
+</project>
12 fetchffeed.py
@@ -0,0 +1,12 @@
+
+from django.core.management import setup_environ
+import settings
+setup_environ(settings)
+
+
+from pystories.services.EntryService import FetchManager
+
+
+fmanager = FetchManager()
+fmanager.triggerfetchFeed()
+
39 logging.conf
@@ -0,0 +1,39 @@
+[loggers]
+keys=root,doloto.pystories
+
+[handlers]
+keys=consoleHandler,rfileHandler
+
+[formatters]
+keys=simpleFormatter
+
+[logger_doloto.pystories]
+level=DEBUG
+handlers=consoleHandler,rfileHandler
+qualname=doloto
+propagate=0
+
+[logger_root]
+level=DEBUG
+handlers=consoleHandler,rfileHandler
+
+[handler_consoleHandler]
+class=StreamHandler
+level=DEBUG
+formatter=simpleFormatter
+args=(sys.stdout,)
+
+[handler_rfileHandler]
+class=handlers.RotatingFileHandler
+level=DEBUG
+formatter=simpleFormatter
+args=(%(log_path)s,'a',5000000,5)
+
+[formatter_simpleFormatter]
+format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
+datefmt=
+
+
+
+
+
12 manage.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+from django.core.management import execute_manager
+
+try:
+ import settings # Assumed to be in the same directory.
+except ImportError:
+ import sys
+ sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
+ sys.exit(1)
+
+if __name__ == "__main__":
+ execute_manager(settings)
0  pystories/__init__.py
No changes.
4 pystories/admin.py
@@ -0,0 +1,4 @@
+from pystories.models import NewsEntry
+from django.contrib import admin
+
+admin.site.register(NewsEntry)
42 pystories/models.py
@@ -0,0 +1,42 @@
+from django.db import models
+from django.conf import settings
+import logging
+import logging.config
+import os
+
+logfilename = os.path.join(os.path.dirname(os.path.normpath(os.sys.modules[settings.SETTINGS_MODULE].__file__)),'logging.conf')
+
+# Create your models here.
+#loading the logging configuration
+logging.config.fileConfig(settings.LOG_FILE_NAME,defaults=dict(log_path=settings.LOG_FILE_PATH))
+
+
+#Create module logger
+mlogger = logging.getLogger(__name__)
+mlogger.debug("From settins LOG_FILE_NAME %s LOG_FILE_PATH %s" % (settings.LOG_FILE_NAME,settings.LOG_FILE_PATH))
+
+
+class NewsEntry(models.Model):
+ url = models.URLField(max_length=1024,db_index=True)
+ title = models.CharField(max_length=1024)
+ description = models.TextField(null=True)
+ noofshares = models.IntegerField(default=0)
+ ispopular = models.BooleanField(default=0)
+ #To facilitate the fast retrieval for the queries involving the date
+ pdate = models.DateField(db_index=True)
+ publisheddate = models.DateTimeField()
+ populardate = models.DateTimeField(null=True)
+ entryids = models.TextField(default='')
+
+ def __unicode__(self):
+ return self.url
+
+
+class Feedback(models.Model):
+ publisheddate = models.DateTimeField(auto_now=True)
+ flag = models.CharField(max_length=10)
+
+
+ def __unicode__(self):
+ return "Feedback is %s %s" %(publisheddate,flag)
+
200 pystories/services/EntryService.py
@@ -0,0 +1,200 @@
+import logging
+import feedparser
+import httplib
+import urlparse
+import time
+import datetime
+from pystories.models import NewsEntry
+from django.contrib.syndication.feeds import Feed
+from django.core.paginator import Paginator
+import socket
+
+from django.conf import settings
+
+
+
+#module logger use this logger in the standalone functions
+mlogger = logging.getLogger(__name__)
+
+#feedurl = "http://friendfeed.com/public?format=atom&service=googlereader&num=100"
+#feedurl = "http://friendfeed.com/search?q=%s&who=everyone&service=googler&service=%s&format=atom&num="+settings.NUMBER_OF_ENTRIES
+#News keywords
+#services
+ffservices = ['googlereader','delicious']
+#keywords which we are looking for
+newsli = ['django']
+
+
+class FetchManager:
+
+ def __init__(self):
+ self.logger = logging.getLogger('%s.%s' % (__name__,self.__class__.__name__))
+
+
+
+ def triggerfetchFeed(self):
+ for service in ffservices :
+ self.logger.info("reading from %s" % service)
+ for tag in newsli :
+ furl = "http://friendfeed.com/search?q=%s&who=everyone&service=%s&format=atom&num=%s" % (tag,service,settings.NUMBER_OF_ENTRIES)
+ self.logger.info("freiend feed url = %s "% furl)
+ self.fetchFeed(furl)
+
+
+
+
+ def fetchFeed(self,feedurl):
+ self.logger.info("Entering fetch feed function")
+ self.logger.info("fetching the feed from the friend feed")
+ d = feedparser.parse(feedurl)
+ self.logger.debug("how many entries %s" %len(d['entries']))
+ #for each entry fetch its title and url
+ self.logger.info("iterating filtering the feed entries and saving it to the database")
+ for entry in d['entries']:
+ #is it related to python / django / jquery
+ #only if it is a valid url
+ self.logger.debug("what is the value of entry link %s , %s" % (entry.link,entry.title) )
+ if self.relatedToPython(entry.title) :
+ burl = self.bringBaseUrl(entry.link)
+ self.logger.debug("Base URL is (after eliminating the redirecting url's) %s" % burl)
+ if burl :
+ #this entry is related to python save it in the database
+ self.logger.debug("preparing the NewsEntry object")
+ newslist = NewsEntry.objects.filter(url=burl)
+ self.logger.debug("length of newslist %s" % len(newslist))
+ if len(newslist) > 0 :
+ self.logger.debug("There is news entry with this URL checking for duplicates......... ")
+ aflag = 0
+ oldentry = newslist[0]
+ lentryids = oldentry.entryids.split(";")
+ for eid in lentryids :
+ if eid == entry.id :
+ self.logger.info("not saving entry already exists")
+ aflag = 1
+ break
+
+ if aflag == 1 :
+ continue
+
+ self.logger.debug("The present entry is itself an unique one>> so increment the shares")
+ lentryids.append(entry.id)
+ oldentry.entryids = ";".join(lentryids)
+ oldentry.noofshares = oldentry.noofshares + 1
+ oldentry.save()
+ else :
+ #creates a new entry now
+ self.logger.debug("There is no news entry with this URL so saving this ")
+ ne = NewsEntry()
+ ne.url = burl
+ #preprocess the title
+ start = entry.title.find(":")
+ end = entry.title.find("(via")
+ ne.title = entry.title[start+1:end].strip()
+ if(self.isItInEnglish(ne.title)) :
+ ne.noofshares = 1
+ self.logger.debug("published_parsed date from universal feed parser %s" %entry.published_parsed)
+ year,month,day,hour,min,second,asd,asdfk,asdfd = entry.published_parsed
+ ne.publisheddate = datetime.datetime(year,month,day,hour,min,second)
+ ne.pdate = datetime.date(year,month,day)
+ self.logger.debug("publisheddate = %s pdate = %s" %(ne.publisheddate,ne.pdate))
+ ne.entryids = entry.id
+ ne.save()
+
+
+ def isItInEnglish(self,title):
+ self.logger.debug("checking whether the title is in english or not")
+ for c in title:
+ if ord(c) > 256 :
+ self.logger.debug("c = %s , interger = %d" %(c,ord(c)))
+ return None
+ return 1
+
+
+
+ def relatedToPython(self,title):
+ self.logger.info("Checking whether this entry is related to python,django or not")
+ for word in newsli:
+ if title.lower().find(word) >= 0 :
+ self.logger.debug("this entry is related to python,django etc...")
+ return 1
+
+ self.logger.debug("this entry is not related to python,django,jquery etc.....")
+ return None
+
+
+ def bringBaseUrl(self,url):
+ self.logger.info("Bringing down the base URL")
+ maxattempts = 5
+ turl = url
+ while (maxattempts > 0) :
+ self.logger.debug("what is the url=%s" % turl)
+ host,path = urlparse.urlsplit(turl)[1:3]
+ if len(host.strip()) == 0 :
+ return None
+ #self.logger.debug("what is the host %s and path is %s"%(host,path))
+ try:
+ connection = httplib.HTTPConnection(host)
+ connection.request("HEAD", path)
+ resp = connection.getresponse()
+ #attempted
+ except httplib.HTTPException:
+ self.logger.debug("Could not open socket some network exception")
+ return None
+ maxattempts = maxattempts - 1
+ if (resp.status >= 300) and (resp.status <= 399):
+ self.logger.debug("The present %s is a redirection one" %turl)
+ turl = resp.getheader('location')
+ elif (resp.status >= 200) and (resp.status <= 299) :
+ self.logger.debug("The present url %s is a proper one" %turl)
+ return turl
+ else :
+ #some problem with this url
+ return None
+
+ return None
+
+ def getPopularNews(self) :
+ self.logger.info("Fetching the poular news stories related to python django and jquery ")
+ #get all the popular stories ordered by noofshares and date
+ #get GMT-5 days date
+ year,month,day,hour,min,second,asd,asdfk,asdfd = datetime.datetime.utctimetuple(datetime.datetime.now())
+ todaygmt = datetime.date(year,month,day)
+ self.logger.debug("what is the today GMT date %s" % todaygmt)
+ self.logger.debug("what is the window size %s" % settings.WINDOW_SIZE)
+ five_days = datetime.timedelta(days=settings.WINDOW_SIZE)
+ #finding 5 days back date
+ dfivedate = todaygmt - five_days
+ self.logger.debug("5 days back GMT date %s" % dfivedate)
+ paginator = Paginator(NewsEntry.objects.filter(pdate__gte = dfivedate).order_by('-noofshares','-publisheddate'),settings.WIDGET_PAGE_SIZE)
+ topnewslist = paginator.page(1)
+ mlogger.debug("length topnewlist = %s " % len(topnewslist.object_list))
+ return topnewslist.object_list
+ #pass the list to the template
+
+
+
+class LatestEntries(Feed) :
+ title_template = 'pystories/feeds/title.html'
+ description_template = 'pystories/feeds/description.html'
+
+ title = "Django latest popular stories feed"
+ link = "http://www.uswaretech.com/blog/"
+ description = "Latest stories on Django."
+
+ # def __init__(self):
+ # self.logger = logging.getLogger('%s.%s' % (__name__,self.__class__.__name__))
+
+
+ def item_link(self,obj):
+ return obj.url
+
+ def item_pubdate(self,obj):
+ return obj.publisheddate
+
+ def items(self):
+ fmanager = FetchManager()
+ return fmanager.getPopularNews()
+
+
+
+
0  pystories/services/__init__.py
No changes.
19 pystories/urls.py
@@ -0,0 +1,19 @@
+from django.conf.urls.defaults import *
+from django.conf import settings
+
+from django.contrib.syndication.views import feed
+
+from pystories.services.EntryService import LatestEntries
+
+
+feeds = {
+ 'recent': LatestEntries
+}
+
+
+urlpatterns = patterns('pystories.views',
+ (r'^welcome/$','index'),
+ (r'^postfeedback/$','handleFeedback'),
+ (r'^widget/$','buildwidget'),
+ (r'^feeds/(?P<url>.*)/$', feed , {'feed_dict': feeds})
+ )
54 pystories/views.py
@@ -0,0 +1,54 @@
+# Create your views here.
+from django.http import HttpResponse
+from django.core.paginator import Paginator
+from django.template import Context , loader
+from django.http import HttpResponse
+from django.conf import settings
+
+from pystories.services.EntryService import FetchManager
+from pystories.models import NewsEntry , Feedback
+
+import logging
+import datetime
+
+#Create module logger
+#several logging configurations are configured in the models
+mlogger = logging.getLogger(__name__)
+
+
+def index(request) :
+ mlogger.info("Function index : view.py")
+ fmanager = FetchManager()
+ topnewslist = fmanager.getPopularNews()
+ vw = loader.get_template("pystories/index.html")
+ c = Context({
+ 'topnewslist': topnewslist,
+ 'iframe_url': settings.IFRAME_URL,
+ 'site_url': settings.SITE_URL
+ })
+ return HttpResponse(vw.render(c))
+
+
+def handleFeedback(request) :
+ mlogger.info("handling the feedback")
+ feedback = Feedback()
+ feedback.flag = request.POST['feedback_value']
+ mlogger.debug("what is the feedback="+feedback.flag)
+ feedback.save()
+
+ return HttpResponse("success","text")
+
+def buildwidget(request) :
+ mlogger.info("Function in buildwidget")
+ fmanager = FetchManager()
+ topnewslist = fmanager.getPopularNews()
+ vw = loader.get_template("pystories/onlywidget.html")
+ c = Context({
+ 'topnewslist': topnewslist
+ })
+ return HttpResponse(vw.render(c))
+
+
+
+
+
72 settings.py
@@ -0,0 +1,72 @@
+# Django settings for doloto project.
+
+from localsettings import *
+
+import os
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'America/Chicago'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/media/'
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 't9eow#2=q94y4xh=+3&0(m#v)4n(&zm))2%euv2h)jc!0uumu!'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.load_template_source',
+ 'django.template.loaders.app_directories.load_template_source',
+# 'django.template.loaders.eggs.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+)
+
+
+
+INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.admin',
+ 'pystories'
+)
+
+#number of entries has to fecthed each time from friendfeed
+NUMBER_OF_ENTRIES = '20'
+
+#use for determining the popular stories
+WINDOW_SIZE = 2
+
+#LOG_FILE_PATH in django
+LOG_FILE_PATH = "\""+os.path.join(os.path.join(os.path.dirname(os.path.normpath(__file__)),'logs'),"logs.txt")+"\""
+
+#LOG FILE NAME In django
+logfilename = os.path.join(os.path.dirname(os.path.normpath(__file__)),'logging.conf')
+LOG_FILE_NAME = logfilename
+
+#number of entries to be displayed on the widget
+WIDGET_PAGE_SIZE = 10
+
+
89 site_media/pystories/css/onlywidget.css
@@ -0,0 +1,89 @@
+body {
+ font-family : Verdana,sans-serifs;
+ font-size :14px;
+ padding : 0px;
+ margin : 0px;
+}
+
+#widgetheader
+{
+ background : #EFEFEF;
+ border-top : 0px solid #DDDDDD;
+ border-left : 0px solid #DDDDDD;
+ border-right : 0px solid #DDDDDD;
+ border-bottom : 1px solid #DDDDDD;
+ padding : 5px;
+ padding-right : 6px;
+ font-size : 105%;
+}
+
+#footer
+{
+ background : #EFEFEF;
+ border-top : 1px solid #DDDDDD;
+ border-bottom : 0px solid #DDDDDD;
+ border-left : 0px solid #DDDDDD;
+ border-right : 0px solid #DDDDDD;
+ padding : 3px;
+ padding-left : 6px;
+ font-size : 80%;
+}
+
+#footer a:link { color : black; text-decoration:none } /* Unvisited links */
+#footer a:visited { text-decoration : none; color : black ; } /* visited link */
+#footer a:hover { text-decoration : underline; color : #2361A1 } /* mouse over link */
+
+
+a:link { color : #2361A1; text-decoration:none } /* Unvisited links */
+a:visited { text-decoration : none; color : #2361A1; } /* visited link */
+a:hover { text-decoration : underline; color : #45A100 } /* mouse over link */
+
+
+
+#widget{
+ border : 1px solid #DDDDDD;
+ color : #111111;
+}
+
+
+img{
+ border : 0px solid black;
+}
+
+
+ul li
+{
+ border-bottom : 1px solid #EEEEEE;
+ padding : 5px;
+ list-style-type:none;
+ margin : 0px;
+
+}
+
+ul li.last
+{
+ border-bottom : 0px solid #EEEEEE;
+ padding : 5px;
+ list-style-type:none;
+ margin : 0px;
+
+}
+
+ul
+{margin : 0px;
+padding : 0px;}
+
+table{
+ font-size : 14px;
+ border-spacing : 0px;
+}
+
+span.small
+{
+ font-size : 80%;
+}
+
+
+
+
+
81 site_media/pystories/css/widget.css
@@ -0,0 +1,81 @@
+body {
+ font-family : Verdana,sans-serif;
+ font-size : 14px;
+}
+
+#leftbox{
+
+ width : 24%;
+ float : left;
+ margin-top : 15px;
+
+}
+
+#rightbox
+{
+ margin-left : 25%;
+ margin-top : 15px;
+}
+
+#lastbox
+{
+ border : 1px solid #CCCCCC;
+ margin-top : 30px;
+ width : 50%;
+ padding : 10px;
+
+}
+
+ #uswarebox
+{
+ width : 50%;
+ margin-top : 30px;
+ padding : 10px;
+ border : 1px solid #A6BFC9;
+}
+
+#middlebox
+{
+ width : 50%;
+ padding : 10px;
+ background : #E0ECF7;
+ border : 1px solid #A6BFC9;
+}
+
+textarea{
+ border : 1px solid #DDDDDD;
+ padding : 5px;
+}
+
+#footer
+{
+ margin-top : 30px;
+}
+
+span.green
+{
+ color:#43845A;
+ font-weight:bold;
+ padding : 5px;
+ }
+
+ p{
+ margin : 0px;
+ padding : 0px;
+ padding-bottom : 8px;
+ }
+
+ #content
+ {
+ border : 1px solid white;
+ }
+
+ span.verysmall
+ {
+ font-size : xx-small;
+ }
+
+
+
+
+
BIN  site_media/pystories/images/feedicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 site_media/pystories/scripts/dolscript.js
@@ -0,0 +1,33 @@
+//document has been loaded
+//create an event for the radio button click
+//the moment he cliks that
+ $(document).ready(function() {
+ $("input.fbutton").click(handleFeedback);
+ $("#widgetcode").click(selectWidgetCode);
+ //select all the code in the textarea
+
+ });
+
+ function handleFeedback()
+ {
+ var value = $("input[@name=feedback]:checked").val();
+ $('#feedbackbox').replaceWith("<span class='green'> Thanks for your feedback</span>");
+ var data = {}
+ data.feedback_value = value;
+ $.post("/pystories/postfeedback/",
+ data,
+ handleResponse,
+ "text"
+ );
+ }
+
+ function selectWidgetCode()
+ {
+ $("#widgetcode").select();
+ }
+
+
+//handle the response data not much to handle now................
+function handleResponse(responseData) {
+
+}
8 site_media/pystories/scripts/iframehadjust.js
@@ -0,0 +1,8 @@
+/*function calcHeight()
+{
+
+ var the_height= document.getElementById('doloto_iframe').contentWindow.document.body.scrollHeight;
+ the_height = the_height + 5;
+ document.getElementById('doloto_iframe').style.height= (the_height+5)+"px";
+
+}*/
4,241 site_media/pystories/scripts/jquery13.js
4,241 additions, 0 deletions not shown
18 site_media/pystories/shtml/testing.html
@@ -0,0 +1,18 @@
+<html>
+
+ <head>
+
+
+ </head>
+ <body>
+
+ <iframe src ="http://localhost:8000/pystories/widget/" onLoad="calcHeight();" id="doloto_iframe" width="275px" height="458px" frameborder="0" scrolling="no"
+ style = "padding-top : 5px">
+ </iframe>
+ <script type="text/javascript" src="http://localhost:8000/site_media/pystories/scripts/iframehadjust.js"></script>
+
+ <body>
+
+
+
+</html>
19 templates/pystories/base.html
@@ -0,0 +1,19 @@
+<html>
+
+<head>
+ <link type="text/css" rel="stylesheet" href="/site_media/pystories/css/widget.css">
+ <link rel="alternate" type="application/rss+xml" title="Django popular stories feed" href="http://feeds2.feedburner.com/uswaretech-django-popular-stories">
+</head>
+
+<body>
+
+{% block content %}{% endblock %}
+
+<div id="footer">
+</div>
+
+
+
+<script type="text/javascript" src="/site_media/pystories/scripts/jquery13.js"></script>
+<script type="text/javascript" src="/site_media/pystories/scripts/dolscript.js"></script>
+</body>
5 templates/pystories/feeds/description.html
@@ -0,0 +1,5 @@
+{% if obj.description %}
+ {{ obj.description }}
+{% endif %}
+
+
1  templates/pystories/feeds/title.html
@@ -0,0 +1 @@
+{{ obj.title }}
52 templates/pystories/index.html
@@ -0,0 +1,52 @@
+{% extends "pystories/base.html" %}
+
+{% block content %}
+
+<div id="content">
+<div id="leftbox">
+
+ <iframe src ="/pystories/widget/" id="doloto_iframe" frameborder=0 border=0 width="250px" height="650px"
+ style = "padding-top : 5px">
+ </iframe>
+
+</div>
+
+
+<div id="rightbox">
+
+ <div id="middlebox">
+ <p>Use the following code to embed the widget*: <br/>
+ <textarea id="widgetcode" cols="45" rows="6"><iframe src ="{{iframe_url}}" id="doloto_iframe" width="250px" height="525px" frameborder=0 border=0 style = "padding-top : 5px"> </iframe>
+ </textarea>
+ </p>
+ <span class="verysmall"> * Please modify the width and height of the iframe suitable to your needs.</span>
+ </div>
+
+ <div id="uswarebox">
+ By crunching social media (Google Reader, friendfeed, delicious, magnolia, ...) using an algorithm, we bring the top stories in django , to this embeddable widget. It is constantly updated! <a href="http://uswaretech.com/blog/2009/02/django-popular-stories-widget/">More details on our blog</a>.
+ <br/>
+ </div>
+
+ <div id="lastbox">
+ <p> Would you like to see such popular stories on more topics? </p>
+ <p id="feedbackbox">
+ <INPUT type="radio" name="feedback" value="Yes" class="fbutton">Yes</input> &nbsp; &nbsp;
+ <INPUT type="radio" name="feedback" value="No" class="fbutton">No </input>
+ </p>
+ </div>
+
+
+ <div id="footer">
+ Built by <a href="http://uswaretech.com/"> uswaretech.com </a>
+ </div>
+
+</div>
+
+<div>
+
+{% endblock %}
+
+
+
+
+
43 templates/pystories/onlywidget.html
@@ -0,0 +1,43 @@
+<html>
+
+<head>
+
+ <link type="text/css" rel="stylesheet" href="/site_media/pystories/css/onlywidget.css">
+
+</head>
+
+<body >
+
+<div id="widget" >
+
+ <table>
+ <tr>
+ <td id="widgetheader">
+ What's up in the django world?<a href="http://feeds2.feedburner.com/uswaretech-django-popular-stories" target="_blank"> <img src="/site_media/pystories/images/feedicon.png" alt="Doloto Rss icon" /> </a>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <ul id="contents">
+ {% for newsentry in topnewslist %}
+ {% if forloop.last %}
+ <li class="last"> <a href="{{newsentry.url}}" target="_blank"> {{newsentry.title}} </a> </li>
+ {% else %}
+ <li> <a href="{{newsentry.url}}" target="_blank"> {{newsentry.title}} </a> </li>
+ {% endif %}
+ {% endfor %}
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td id="footer">
+
+ <span style="float:left"> <a href="/pystories/welcome/" target="_blank" > embed this widget </a> </span>
+ <span style="float:right"> <a href="/blog/"target="_blank" > uswaretech.com </a> </span>
+ </td>
+ </tr>
+ </table>
+</div>
+
+</body>
+
24 urls.py
@@ -0,0 +1,24 @@
+from django.conf.urls.defaults import *
+from django.conf import settings
+from django.contrib import admin
+
+admin.autodiscover()
+
+from django.conf import settings
+import os
+dirname = os.path.dirname(globals()["__file__"])
+
+
+
+urlpatterns = patterns('',
+ (r'^admin/(.*)',admin.site.root),
+ (r'^pystories/',include('pystories.urls')),
+
+)
+
+if settings.DEBUG:
+ media_dir = os.path.join(dirname, 'site_media')
+ urlpatterns += patterns('',
+ url(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': media_dir}),
+ )
+
Please sign in to comment.
Something went wrong with that request. Please try again.