Skip to content

Commit

Permalink
updated w3c/rfc TOC parts
Browse files Browse the repository at this point in the history
  • Loading branch information
staffanm committed Jul 9, 2014
1 parent 8862551 commit defa9e2
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 10 deletions.
3 changes: 2 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ Classes
api/textreader
api/pdfreader
api/wordreader
..
api/wsgiapp
api/resources
api/resources -- these are not yet public api
Modules
-------
Expand Down
5 changes: 3 additions & 2 deletions ferenda/facet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from rdflib import URIRef, Namespace
from rdflib.namespace import RDF, RDFS, DC, SKOS, FOAF, DCTERMS
SCHEMA = Namespace("http://schema.org/")
BIBO = Namespace("http://purl.org/ontology/bibo/")

from ferenda import fulltextindex # to get the IndexedType classes
from ferenda import util
Expand Down Expand Up @@ -195,7 +196,7 @@ def resourcelabel(cls, row, binding='dcterms_publisher', resource_graph=None):
'Chapman & Hall'
"""
uri = URIRef(row[binding])
for pred in (RDFS.label, SKOS.prefLabel, SKOS.altLabel, DCTERMS.title, DCTERMS.alternative, FOAF.name):
for pred in (RDFS.label, SKOS.prefLabel, SKOS.altLabel, DCTERMS.title, DCTERMS.alternative, FOAF.name, BIBO.identifier):
if resource_graph.value(uri, pred):
return str(resource_graph.value(uri, pred))
else:
Expand Down Expand Up @@ -354,7 +355,7 @@ def __eq__(self, other):
DCTERMS.identifier: {
'indexingtype': fulltextindex.Label(boost=16),
'toplevel_only': False,
'use_for_toc': True,
'use_for_toc': False, # typically no info that isn't already in title
'selector': Facet.firstletter,
'key': Facet.titlesortkey,
'identificator': Facet.firstletter,
Expand Down
7 changes: 7 additions & 0 deletions ferenda/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
from ferenda import util, errors

class Resources(object):
"""Creates and manages various assets/resources needed for web serving.
This class is not yet part of the public API -- clients should use
manager.makeresources for now.
"""

def __init__(self, repos, resourcedir, **kwargs):
# FIXME: document what kwargs could be (particularly 'combineresources')
self.repos = repos
Expand Down
19 changes: 16 additions & 3 deletions ferenda/sources/tech/rfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,25 @@ def parse_header(self, header, desc):
desc.value(self.ns['dcterms'].rightsHolder, line)

def facets(self):
def select_rfcnum(row, binding, resource_graph):
# "RFC 6998" -> "6900"
return row[binding][4:-2] + "00"

return [Facet(self.ns['rdf'].type),
Facet(self.ns['dcterms'].identifier),
Facet(self.ns['dcterms'].identifier,
label="Sorted by RFC #",
pagetitle="RFC %(selected)s00-%(selected)s99",
selector=select_rfcnum,
use_for_toc=True),
Facet(self.ns['dcterms'].title),
Facet(self.ns['dcterms'].publisher),
Facet(self.ns['dcterms'].publisher,
label="Sorted by stream",
pagetitle="The %(selected)s stream"),
Facet(self.ns['dcterms'].issued),
Facet(self.ns['dcterms'].subject)]
Facet(self.ns['dcterms'].subject, # should be rfc:category not dcterms:status?
label="Sorted by status",
pagetitle="Status: %(selected)s")]

def toc_item(self, binding, row):
return [row['dcterms_identifier'] + ": ",
Link(row['dcterms_title'],
Expand Down
12 changes: 11 additions & 1 deletion ferenda/sources/tech/w3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
from rdflib import Literal, Graph, URIRef, RDF, Namespace

from .rfc import PreambleSection
from ferenda import Describer, DocumentRepository, FSMParser
from ferenda import Describer, DocumentRepository, FSMParser, Facet
from ferenda import util, decorators
from ferenda.elements import serialize, html, Body, Section, Subsection, Subsubsection
DCTERMS = Namespace(util.ns['dcterms'])


class W3Standards(DocumentRepository):
Expand Down Expand Up @@ -292,5 +293,14 @@ def decorate_bodyparts(self, part, baseuri):
for subpart in part:
self.decorate_bodyparts(subpart, baseuri)

def facets(self):
return [Facet(RDF.type),
Facet(DCTERMS.title),
# Facet(DCTERMS.publisher), -- is always w3c
Facet(DCTERMS.identifier),
Facet(DCTERMS.issued)
]


def tabs(self):
return [("W3C standards", self.dataset_uri())]
12 changes: 9 additions & 3 deletions ferenda/wsgiapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
from ferenda.elements import html

class WSGIApp(object):
"""Implements a WSGI app.
This class is not yet part of the public API -- clients should use
manager.make_wsgi_app for now.
"""
def __init__(self, repos, inifile=None, **kwargs):
self.repos = repos
# FIXME: need to specify documentroot?
Expand Down Expand Up @@ -428,13 +434,13 @@ def _guess_real_fieldname(k, schema):


def _str(self, s, encoding="ascii"):
"""If running under python2.6, return byte string version of the
"""If running under python2, return byte string version of the
argument, otherwise return the argument unchanged.
Needed since wsgiref under python 2.6 hates unicode.
Needed since wsgiref under python 2 hates unicode.
"""
if sys.version_info < (2, 7, 0):
if sys.version_info < (3, 0, 0):
return s.encode("ascii") # pragma: no cover
else:
return s
Expand Down

0 comments on commit defa9e2

Please sign in to comment.