NarrativeWeb: Feature Request: #4232 -- Repository is now hyperlinked to its source.

svn: r15885
This commit is contained in:
Rob G. Healey 2010-09-13 04:55:47 +00:00
parent 65f9fdd404
commit d6ca13254c
3 changed files with 116 additions and 62 deletions

View File

@ -1884,16 +1884,28 @@ class BasePage(object):
# return thumbnail division to its callers # return thumbnail division to its callers
return thumbnail return thumbnail
def repository_link(self, handle, name, cindex, gid = None, up = False): def repository_link(self, handle, name, repo_yes, gid = None, up = False):
"""
returns a hyperlink for repository links
@param: handle -- repository handle
@param: name -- repository title
@param: gid -- gramps id
@param: up -- whether to add backward reference
"""
name = html_escape( name )
# build local page url
url = self.report.build_url_fname_html(handle, 'repo', up) url = self.report.build_url_fname_html(handle, 'repo', up)
# begin hyperlink # begin hyperlink
hyper = Html("a", html_escape(name), href = url, title = name) hyper = Html("a", name, href = url, title = name)
if not self.noid and gid: if not self.noid and gid:
hyper += Html("span", '[%s]' % gid, class_ = "grampsid", inline = True) hyper += Html("span", '[%s]' % gid, class_ = "grampsid", inline = True)
# return hyperlink to its callers # return hyperlink to its callers
return hyper return hyper if repo_yes else name
def place_link(self, handle, name, gid = None, up = False): def place_link(self, handle, name, gid = None, up = False):
@ -3474,72 +3486,97 @@ class SourcePage(BasePage):
db = report.database db = report.database
source = db.get_source_from_handle(handle) source = db.get_source_from_handle(handle)
if source is not None: if not source:
BasePage.__init__(self, report, title, source.gramps_id) return
of = self.report.create_file(source.get_handle(), "src") BasePage.__init__(self, report, title, source.gramps_id)
self.up = True inc_repos = self.report.options["inc_repository"]
sourcepage, head, body = self.write_header(_('Sources'))
# begin source detail division of = self.report.create_file(source.get_handle(), "src")
with Html("div", class_ = "content", id = "SourceDetail") as section: self.up = True
body += section sourcepage, head, body = self.write_header(_('Sources'))
media_list = source.get_media_list() # begin source detail division
thumbnail = self.display_first_image_as_thumbnail(media_list, source) with Html("div", class_ = "content", id = "SourceDetail") as srcdetail:
if thumbnail is not None: body += srcdetail
section += thumbnail
# add section title media_list = source.get_media_list()
section += Html("h3", html_escape(source.get_title()), inline = True) thumbnail = self.display_first_image_as_thumbnail(media_list, source)
if thumbnail is not None:
srcdetail += thumbnail
# begin sources table # add section title
with Html("table", class_ = "infolist source") as table: srcdetail += Html("h3", html_escape(source.get_title()), inline = True)
section += table
tbody = Html("tbody") # begin sources table
table += tbody with Html("table", class_ = "infolist source") as table:
srcdetail += table
grampsid = None tbody = Html("tbody")
if not self.noid and self.gid: table += tbody
grampsid = self.gid
for (label, val) in [ grampsid = None
(GRAMPSID, grampsid), if not self.noid and self.gid:
(_("Author"), source.author), grampsid = self.gid
(_("Publication information"), source.pubinfo),
(_("Abbreviation"), source.abbrev) ]:
if val: for (label, val) in [
trow = Html("tr") + ( (GRAMPSID, grampsid),
Html("td", label, class_ = "ColumnAttribute"), (_("Author"), source.author),
Html("td", val, class_ = "ColumnValue") (_("Publication information"), source.pubinfo),
) (_("Abbreviation"), source.abbrev) ]:
tbody += trow
# additional media if val:
sourcemedia = self.display_additional_images_as_gallery(media_list, source) trow = Html("tr") + (
if sourcemedia is not None: Html("td", label, class_ = "ColumnAttribute", inline = True),
section += sourcemedia Html("td", val, class_ = "ColumnValue", inline = True)
)
tbody += trow
# additional notes # additional media
notelist = self.display_note_list( source.get_note_list() ) sourcemedia = self.display_additional_images_as_gallery(media_list, source)
if notelist is not None: if sourcemedia is not None:
section += notelist srcdetail += sourcemedia
# references # additional notes
references = self.display_references(src_list[source.handle]) notelist = self.display_note_list( source.get_note_list() )
if references is not None: if notelist is not None:
section += references srcdetail += notelist
# add clearline for proper styling # source repository list
# add footer section repo_ref_list = source.get_reporef_list()
footer = self.write_footer() if repo_ref_list:
body += (fullclear, footer) with Html("div", id = "subsection", class_ = "Repositories") as reposection:
srcdetail += reposection
reposection += Html("h4", _("Repositories"), inline = True)
# send page out for processing with Html("table", class_ = "infolist repolist") as table:
# and close the file reposection += table
self.XHTMLWriter(sourcepage, of)
unordered = Html("ul")
table += unordered
for repo_ref in repo_ref_list:
repository = db.get_repository_from_handle( repo_ref.ref )
list = Html("li", self.repository_link( repository.handle,
repository.name,
inc_repos,
repository.gramps_id,
up = True ) )
unordered += list
# references
references = self.display_references(src_list[source.handle])
if references is not None:
srcdetail += references
# add clearline for proper styling
# add footer section
footer = self.write_footer()
body += (fullclear, footer)
# send page out for processing
# and close the file
self.XHTMLWriter(sourcepage, of)
class MediaListPage(BasePage): class MediaListPage(BasePage):
@ -5218,8 +5255,10 @@ class RepositoryListPage(BasePage):
""" """
def __init__(self, report, title, repos_dict, keys): def __init__(self, report, title, repos_dict, keys):
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
db = report.database db = report.database
inc_repos = self.report.options["inc_repository"]
of = self.report.create_file("repositories") of = self.report.create_file("repositories")
repolistpage, head, body = self.write_header(_("Repositories")) repolistpage, head, body = self.write_header(_("Repositories"))
@ -5266,10 +5305,13 @@ class RepositoryListPage(BasePage):
# repository name and hyperlink # repository name and hyperlink
if repo.name: if repo.name:
trow += Html("td", self.repository_link(handle, repo.name, repo.gramps_id), trow += Html("td", self.repository_link( handle,
class_ = "ColumnName") repo.name,
inc_repos,
repo.gramps_id ),
class_ = "ColumnName")
else: else:
trow += Html("td", " ", class_ = "ColumnName") trow += Html("td", "[ untitled ]", class_ = "ColumnName")
# add clearline for proper styling # add clearline for proper styling
# add footer section # add footer section

View File

@ -116,7 +116,7 @@ img {
background-color: #FFF; background-color: #FFF;
color: #000; color: #000;
overflow: auto; overflow: auto;
width: 1060px; width: 100%;
margin: 0 auto; margin: 0 auto;
} }
.content div.snapshot { .content div.snapshot {
@ -846,8 +846,14 @@ div#Sources table.infolist tbody tr td.ColumnName a {
font-size:.9em; font-size:.9em;
padding:.1em 10px .3em 10px; padding:.1em 10px .3em 10px;
} }
div#SourceDetail table.source tbody tr td.ColumnAttribute {
width: 40%;
}
div#SourceDetail table.source tbody td td.ColumnValue {
width: 40%;
}
div#SourceDetail div#references ol li { div#SourceDetail div#references ol li {
padding-bottom:.5em; padding-bottom: .5em;
} }
@ -869,6 +875,12 @@ div#RepositoryList table.repolist tbody tr td.ColumnType {
div#RepositoryList table.repolist tbody tr td.ColumnName { div#RepositoryList table.repolist tbody tr td.ColumnName {
width: 80%; width: 80%;
} }
div#RepositoryDetail table.repolist tbody tr td.ColumnAttribute {
width: 40%;
}
div#RepositoryDetail table.repolist tbody tr td.ColumnValue {
width: 40%;
}
/* Address Book /* Address Book
------------------------------------------------------ */ ------------------------------------------------------ */

View File

@ -31,8 +31,8 @@ Style Name: Web_Navigation-Horizontal.css
----------------------------------------------------- */ ----------------------------------------------------- */
body { body {
margin: 0 auto; margin: 0 auto;
padding: 0px 4px 0px 4px; padding: 5px 2px 5px 2px;
width: 1060px; width: 965px;
} }
/* Navigation /* Navigation