Initial support for opml-top100

This commit is contained in:
Sam Ruby 2006-08-22 13:18:43 -04:00
parent 87f99e8a01
commit 8844223b7b
9 changed files with 88 additions and 253 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -1,150 +0,0 @@
body {
border-right: 1px solid black;
margin-right: 200px;
padding-left: 20px;
padding-right: 20px;
}
h1 {
margin-top: 0px;
padding-top: 20px;
font-family: "Bitstream Vera Sans", sans-serif;
font-weight: normal;
letter-spacing: -2px;
text-transform: lowercase;
text-align: right;
color: grey;
}
.admin {
text-align: right;
}
h2 {
font-family: "Bitstream Vera Sans", sans-serif;
font-weight: normal;
color: #200080;
margin-left: -20px;
}
h3 {
font-family: "Bitstream Vera Sans", sans-serif;
font-weight: normal;
background-color: #a0c0ff;
border: 1px solid #5080b0;
padding: 4px;
}
h3 a {
text-decoration: none;
color: inherit;
}
h4 {
font-family: "Bitstream Vera Sans", sans-serif;
font-weight: bold;
}
h4 a {
text-decoration: none;
color: inherit;
}
img.face {
float: right;
margin-top: -3em;
}
.entry {
margin-bottom: 2em;
}
.entry .date {
font-family: "Bitstream Vera Sans", sans-serif;
color: grey;
}
.entry .date a {
text-decoration: none;
color: inherit;
}
.sidebar {
position: absolute;
top: 0px;
right: 0px;
width: 200px;
margin-left: 0px;
margin-right: 0px;
padding-right: 0px;
padding-top: 20px;
padding-left: 0px;
font-family: "Bitstream Vera Sans", sans-serif;
font-size: 85%;
}
.sidebar h2 {
font-size: 110%;
font-weight: bold;
color: black;
padding-left: 5px;
margin-left: 0px;
}
.sidebar ul {
padding-left: 1em;
margin-left: 0px;
list-style-type: none;
}
.sidebar ul li:hover {
color: grey;
}
.sidebar ul li a {
text-decoration: none;
}
.sidebar ul li a:hover {
text-decoration: underline;
}
.sidebar ul li a img {
border: 0;
}
.sidebar p {
border-top: 1px solid grey;
margin-top: 30px;
padding-top: 10px;
padding-left: 5px;
}
.sidebar .message {
cursor: help;
border-bottom: 1px dashed red;
}
.sidebar a.message:hover {
cursor: help;
background-color: #ff0000;
color: #ffffff !important;
text-decoration: none !important;
}
a:hover {
text-decoration: underline !important;
color: blue !important;
}

View File

@ -1,67 +0,0 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:planet="http://planet.intertwingly.net/"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="atom:feed">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="planet.css" type="text/css" />
<title><xsl:value-of select="atom:title"/></title>
</head>
<body>
<h1><xsl:value-of select="atom:title"/></h1>
<xsl:apply-templates select="atom:entry"/>
<div class="sidebar">
<img src="images/logo.png" width="136" height="136" alt=""/>
<h2>Subscriptions</h2>
<ul>
<xsl:for-each select="planet:source">
<xsl:sort select="planet:name"/>
<li>
<a href="{atom:link[@rel='self']/@href}" title="subscribe">
<img src="images/feed-icon-10x10.png" alt="(feed)"/>
</a>
<a href="{atom:link[@rel='alternate']/@href}">
<xsl:value-of select="planet:name"/>
</a>
</li>
</xsl:for-each>
</ul>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="atom:entry">
<xsl:variable name="date" select="substring(atom:updated,1,10)"/>
<xsl:if test="not(preceding-sibling::atom:entry
[substring(atom:updated,1,10) = $date])">
<h2 class="date"><xsl:value-of select="$date"/></h2>
</xsl:if>
<h3>
<a href="{atom:source/atom:link[@rel='alternate']/@href}">
<xsl:value-of select="atom:source/planet:name"/>
</a>
&#x2014;
<a href="{atom:link[@rel='alternate']/@href}">
<xsl:value-of select="atom:title"/>
</a>
</h3>
<div class="content">
<xsl:choose>
<xsl:when test="atom:content">
<xsl:copy-of select="atom:content/*"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="atom:summary/*"/>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
</xsl:stylesheet>

View File

@ -88,13 +88,14 @@ def __init__():
def load(config_file):
""" initialize and load a configuration"""
import config, planet
log = planet.getLogger(config.log_level())
global parser
parser = ConfigParser()
parser.read(config_file)
import config, planet
from planet import opml
log = planet.getLogger(config.log_level())
# Theme support
theme = config.output_theme()
if theme:
@ -144,7 +145,7 @@ def load(config_file):
except:
log.exception("Unable to read %s readinglist", list)
continue
planet.opml.opml2config(data, parser)
opml.opml2config(data, parser)
# planet.foaf.foaf2config(data, list, config)
def cache_sources_directory():

View File

@ -25,6 +25,7 @@ illegal_xml_chars = re.compile("[\x01-\x08\x0B\x0C\x0E-\x1F]")
def createTextElement(parent, name, value):
""" utility function to create a child element with the specified text"""
if not value: return
if isinstance(value,str): value=value.decode('utf-8')
xdoc = parent.ownerDocument
xelement = xdoc.createElement(name)
xelement.appendChild(xdoc.createTextNode(value))
@ -64,17 +65,18 @@ def normalize(text, bozo):
def id(xentry, entry):
""" copy or compute an id for the entry """
if entry.has_key("id"):
if entry.has_key("id") and entry.id:
entry_id = entry.id
elif entry.has_key("link"):
elif entry.has_key("link") and entry.link:
entry_id = entry.link
elif entry.has_key("title"):
entry_id = (entry.title_detail.base + "/" +
elif entry.has_key("title") and entry.title:
entry_id = (entry.title_detail.base + "/" +
md5.new(entry.title).hexdigest())
elif entry.has_key("summary"):
entry_id = (entry.summary_detail.base + "/" +
elif entry.has_key("summary") and entry.summary:
entry_id = (entry.summary_detail.base + "/" +
md5.new(entry.summary).hexdigest())
elif entry.has_key("content"):
elif entry.has_key("content") and entry.content:
entry_id = (entry.content[0].base + "/" +
md5.new(entry.content[0].value).hexdigest())
else:

View File

@ -69,7 +69,7 @@ def spiderFeed(feed):
# write each entry to the cache
cache = config.cache_directory()
for entry in data.entries:
if not entry.has_key('id'):
if not entry.has_key('id') or not entry.id:
entry['id'] = reconstitute.id(None, entry)
if not entry['id']: continue

View File

@ -1,13 +1,14 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:planet="http://planet.intertwingly.net/"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output indent="yes" method="html"/>
<xsl:template match="atom:feed">
<html xmlns="http://www.w3.org/1999/xhtml">
<xsl:text>&#10;</xsl:text>
<!-- head -->
<xsl:text>&#10;&#10;</xsl:text>
<head>
<link rel="stylesheet" href="default.css" type="text/css" />
<title><xsl:value-of select="atom:title"/></title>
@ -30,6 +31,7 @@
<xsl:text>&#10;&#10;</xsl:text>
<h2>Subscriptions</h2>
<xsl:text>&#10;</xsl:text>
<ul>
<xsl:for-each select="planet:source">
<xsl:sort select="planet:name"/>
@ -51,7 +53,7 @@
<dl>
<dt>Last updated:</dt>
<dd><span class="date" title="GMT"><xsl:value-of select="atom:updated"/></span></dd>
<dd><span class="date" title="GMT"><xsl:value-of select="atom:updated/@planet:format"/></span></dd>
<dt>Powered by:</dt>
<dd><a href="http://intertwingly.net/code/planet/"><img src="images/planet.png" width="80" height="15" alt="Planet" border="0" /></a></dd>
<dt>Export:</dt>
@ -65,7 +67,11 @@
</div>
<xsl:apply-templates select="atom:entry"/>
<xsl:text>&#10;&#10;</xsl:text>
<div id="body">
<xsl:apply-templates select="atom:entry"/>
<xsl:text>&#10;&#10;</xsl:text>
</div>
</body>
</html>
</xsl:template>
@ -76,7 +82,11 @@
<xsl:if test="not(preceding-sibling::atom:entry
[substring(atom:updated,1,10) = $date])">
<xsl:text>&#10;&#10;</xsl:text>
<h2 class="date"><xsl:value-of select="$date"/></h2>
<h2 class="date">
<xsl:value-of select="substring-before(atom:updated/@planet:format,', ')"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="substring-before(substring-after(atom:updated/@planet:format,', '), ' ')"/>
</h2>
</xsl:if>
<xsl:text>&#10;&#10;</xsl:text>
@ -109,22 +119,14 @@
<!-- entry content -->
<xsl:text>&#10;</xsl:text>
<div class="content">
<xsl:choose>
<xsl:when test="atom:content">
<xsl:if test="atom:content/@xml:lang != @xml:lang">
<xsl:attribute name="xml:lang" select="{atom:content/@xml:lang}"/>
</xsl:if>
<xsl:copy-of select="atom:content/*"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="atom:summary/@xml:lang != @xml:lang">
<xsl:attribute name="xml:lang" select="{atom:summary/@xml:lang}"/>
</xsl:if>
<xsl:copy-of select="atom:summary/*"/>
</xsl:otherwise>
</xsl:choose>
</div>
<xsl:choose>
<xsl:when test="atom:content">
<xsl:apply-templates select="atom:content"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="atom:summary"/>
</xsl:otherwise>
</xsl:choose>
<!-- entry footer -->
<xsl:text>&#10;</xsl:text>
@ -143,11 +145,32 @@
</xsl:when>
</xsl:choose>
<span class="date" title="GMT">
<xsl:value-of select="atom:updated"/>
<xsl:value-of select="atom:updated/@planet:format"/>
</span>
</a>
</div>
</div>
</xsl:template>
<!-- xhtml content -->
<xsl:template match="atom:content/xhtml:div | atom:summary/xhtml:div">
<xsl:copy>
<xsl:if test="@xml:lang != ancestor::atom:entry/@xml:lang">
<xsl:attribute name="xml:lang" select="{atom:content/@xml:lang}"/>
</xsl:if>
<xsl:attribute name="class">content</xsl:attribute>
<xsl:copy-of select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- plain text content -->
<xsl:template match="atom:content/text() | atom:summary/text()">
<div class="content" xmlns="http://www.w3.org/1999/xhtml">
<xsl:if test="@xml:lang != ancestor::atom:entry/@xml:lang">
<xsl:attribute name="xml:lang" select="{atom:summary/@xml:lang}"/>
</xsl:if>
<xsl:copy-of select="."/>
</div>
</xsl:template>
</xsl:stylesheet>

View File

@ -5,7 +5,7 @@
xmlns="http://www.w3.org/1999/xhtml">
<!-- strip planet elements and attributes -->
<xsl:template match="planet:*"/>
<xsl:template match="planet:*|@planet:*"/>
<!-- add Google/LiveJournal-esque noindex directive -->
<xsl:template match="atom:feed">
@ -15,6 +15,32 @@
</xsl:copy>
</xsl:template>
<!-- indent atom elements -->
<xsl:template match="atom:*">
<!-- double space before atom:entries -->
<xsl:if test="self::atom:entry">
<xsl:text>&#10;</xsl:text>
</xsl:if>
<!-- indent start tag -->
<xsl:text>&#10;</xsl:text>
<xsl:for-each select="ancestor::*">
<xsl:text> </xsl:text>
</xsl:for-each>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<!-- indent end tag if there are element children -->
<xsl:if test="*">
<xsl:text>&#10;</xsl:text>
<xsl:for-each select="ancestor::*">
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:if>
</xsl:copy>
</xsl:template>
<!-- pass through everything else -->
<xsl:template match="@*|node()">
<xsl:copy>