2010-08-12 10:56:45 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2010 Douglas Blank <doug.blank@gmail.com>
|
2011-01-22 02:56:17 +05:30
|
|
|
# Copyright (C) 2011 Rob G. Healey <robhealey1@gmail.com>
|
2010-08-12 10:56:45 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id: $
|
|
|
|
|
|
|
|
import os
|
|
|
|
import const
|
|
|
|
from gen.ggettext import sgettext as _
|
|
|
|
|
|
|
|
def make_css_dict(tup):
|
|
|
|
"""
|
|
|
|
Basically, make a named tuple.
|
|
|
|
"""
|
|
|
|
return {
|
|
|
|
"id": tup[0],
|
|
|
|
"user": tup[1],
|
|
|
|
"translation": tup[2],
|
|
|
|
"filename": tup[3],
|
|
|
|
"navigation": tup[4],
|
|
|
|
"images": tup[5],
|
2011-01-22 02:56:17 +05:30
|
|
|
"javascript": tup[6],
|
2010-08-12 10:56:45 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
def load_on_reg(dbstate, uistate, plugin):
|
|
|
|
"""
|
|
|
|
Runs when plugin is registered.
|
|
|
|
"""
|
|
|
|
dir, fname = os.path.split(__file__)
|
2011-03-09 20:46:31 +05:30
|
|
|
from functools import partial
|
|
|
|
path_css = partial(os.path.join, dir, "css")
|
|
|
|
path_img = partial(os.path.join, dir, "images")
|
|
|
|
path_js = partial(os.path.join, dir, "js")
|
2010-08-12 10:56:45 +05:30
|
|
|
CSS_FILES = [
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# id, user selectable?, translated_name, fullpath, navigation target name, images, javascript
|
2010-08-12 10:56:45 +05:30
|
|
|
# "default" is used as default
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# Basic Ash style sheet
|
2010-08-12 10:56:45 +05:30
|
|
|
["Basic-Ash", 1, _("Basic-Ash"),
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Basic-Ash.css'), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# Basic Blue style sheet with navigation menus
|
2010-08-12 10:56:45 +05:30
|
|
|
["Basic-Blue", 1, _("Basic-Blue"),
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Basic-Blue.css'), "narrative-menus.css", [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# Basic Cypress style sheet
|
2010-08-12 10:56:45 +05:30
|
|
|
["Basic-Cypress", 1, _("Basic-Cypress"),
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Basic-Cypress.css'), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# basic Lilac style sheet
|
2010-08-12 10:56:45 +05:30
|
|
|
["Basic-Lilac", 1, _("Basic-Lilac"),
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Basic-Lilac.css'), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# basic Peach style sheet
|
2010-08-12 10:56:45 +05:30
|
|
|
["Basic-Peach", 1, _("Basic-Peach"),
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Basic-Peach.css'), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# basic Spruce style sheet
|
2010-08-12 10:56:45 +05:30
|
|
|
["Basic-Spruce", 1, _("Basic-Spruce"),
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Basic-Spruce.css'), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# Mainz style sheet with its images
|
2010-08-12 10:56:45 +05:30
|
|
|
["Mainz", 1, _("Mainz"),
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Mainz.css'), None,
|
|
|
|
[path_img("Web_Mainz_Bkgd.png"),
|
|
|
|
path_img("Web_Mainz_Header.png"),
|
|
|
|
path_img("Web_Mainz_Mid.png"),
|
|
|
|
path_img("Web_Mainz_MidLight.png")], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# Nebraska style sheet
|
2010-08-12 10:56:45 +05:30
|
|
|
["Nebraska", 1, _("Nebraska"),
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Nebraska.css'), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# Visually Impaired style sheet with its navigation menus
|
2010-08-12 10:56:45 +05:30
|
|
|
["Visually Impaired", 1, _("Visually Impaired"),
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Visually.css'), "narrative-menus.css", [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# no style sheet option
|
|
|
|
["No style sheet",1, _("No style sheet"), [], None, [], []],
|
|
|
|
|
2011-03-08 04:04:38 +05:30
|
|
|
# ancestor tree style sheet and its images
|
2010-08-20 08:03:26 +05:30
|
|
|
["ancestortree", 0, "ancestortree",
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css("ancestortree.css"), None,
|
|
|
|
[path_img("Web_Gender_Female.png"),
|
|
|
|
path_img("Web_Gender_Male.png")], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# media reference regions style sheet
|
2010-08-12 10:56:45 +05:30
|
|
|
["behaviour", 0, "Behaviour",
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('behaviour.css'), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# mapstraction style sheet for NarrativeWeb place maps
|
2011-07-19 03:39:00 +05:30
|
|
|
["mapstraction", 0, "",
|
|
|
|
path_css("narrative-maps.css"), None, [],
|
2011-03-09 20:46:31 +05:30
|
|
|
[path_js("mapstraction", "mxn.core.js"),
|
|
|
|
path_js("mapstraction", "mxn.googlev3.core.js"),
|
|
|
|
path_js("mapstraction", "mxn.js"),
|
|
|
|
path_js("mapstraction", "mxn.openlayers.core.js")] ],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# default style sheet in the options
|
2010-08-12 10:56:45 +05:30
|
|
|
["default", 0, _("Basic-Ash"),
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Basic-Ash.css'), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# default printer style sheet
|
2010-08-12 10:56:45 +05:30
|
|
|
["Print-Default", 0, "Print-Default",
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Print-Default.css'), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# vertical navigation style sheet
|
2010-08-12 10:56:45 +05:30
|
|
|
["Navigation-Vertical", 0, "Navigation-Vertical",
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Navigation-Vertical.css'), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# horizontal navigation style sheet
|
2010-08-12 10:56:45 +05:30
|
|
|
["Navigation-Horizontal", 0, "Navigation-Horizontal",
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css('Web_Navigation-Horizontal.css'), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# GeoView style sheet with its image
|
|
|
|
["GeoView", 0, "GeoView",
|
2011-03-09 20:46:31 +05:30
|
|
|
path_css("GeoView.css"), None,
|
|
|
|
[path_img("crosshairs.png"),
|
|
|
|
path_img("gramps-geo-altmap.png"),
|
|
|
|
path_img("gramps-geo-birth.png"),
|
|
|
|
path_img("gramps-geo-death.png"),
|
|
|
|
path_img("gramps-geo-mainmap.png"),
|
|
|
|
path_img("gramps-geo-marriage.png")],
|
|
|
|
|
|
|
|
[path_js("mapstraction", "mxn.core.js"),
|
|
|
|
path_js("mapstraction", "mxn.googlev3.core.js"),
|
|
|
|
path_js("mapstraction", "mxn.js"),
|
|
|
|
path_js("mapstraction", "mxn.openlayers.core.js")]],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# all other images for use in NarrativeWeb
|
2010-08-12 10:56:45 +05:30
|
|
|
['All Images', 0, 'All Images', None, None,
|
2011-03-09 20:46:31 +05:30
|
|
|
[path_img("blank.gif"),
|
|
|
|
path_img("document.png")], []],
|
2011-03-08 02:12:00 +05:30
|
|
|
|
|
|
|
# Gramps Fav icon #2
|
2011-03-08 04:04:38 +05:30
|
|
|
["favicon2", 0, "favicon2",
|
2011-03-09 20:46:31 +05:30
|
|
|
path_img("favicon2.ico"), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# copyright image
|
2011-03-08 04:04:38 +05:30
|
|
|
['Copyright', 0, 'Copyright',
|
2011-03-09 20:46:31 +05:30
|
|
|
path_img("somerights20.gif"), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# document image in case the media object is not an image
|
2011-03-09 20:46:31 +05:30
|
|
|
['Document', 0, 'Document',
|
|
|
|
path_img("document.png"), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# Google core javascript
|
2011-03-09 20:46:31 +05:30
|
|
|
["Google Core", 0, "Google Core",
|
|
|
|
path_js("mapstraction", "mxn.google.core.js"), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# Google Earth core javascript
|
|
|
|
["Google Earth", 0, "Google Earth",
|
2011-03-09 20:46:31 +05:30
|
|
|
path_js("mapstraction", "mxn.googleearth.core.js"), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
|
|
|
# Google GeoCoder javascript
|
|
|
|
["Google GeoCoder", 0, "Google GeoCoder",
|
2011-03-09 20:46:31 +05:30
|
|
|
path_js("mapstraction", "mxn.google.geocoder.js"), None, [], []],
|
2011-01-22 02:56:17 +05:30
|
|
|
|
2010-08-12 10:56:45 +05:30
|
|
|
]
|
2011-03-09 20:46:31 +05:30
|
|
|
|
2010-08-12 10:56:45 +05:30
|
|
|
return CSS_FILES
|
|
|
|
|
|
|
|
def process_list(data):
|
|
|
|
"""
|
|
|
|
Gather all of the web resources together, and allow override files
|
|
|
|
if available.
|
|
|
|
"""
|
|
|
|
retval = []
|
|
|
|
for row in data:
|
|
|
|
file = row[3]
|
|
|
|
if file:
|
|
|
|
path, filename = os.path.split(file)
|
|
|
|
# is there a override file in the VERSION_DIR/webstuff?
|
|
|
|
# eg, ~/.gramps/gramps33/webstuff/Web_Nebraska.css
|
|
|
|
# if so, replace this one:
|
|
|
|
override = os.path.join(const.VERSION_DIR, "webstuff", filename)
|
|
|
|
if os.path.exists(override):
|
|
|
|
row[3] = override
|
|
|
|
retval.append(row)
|
|
|
|
# {"Mainz": {"id": "Mainz", "user":1, ...}}
|
|
|
|
retdict = {}
|
|
|
|
for css in retval:
|
|
|
|
if css[0] in retdict:
|
|
|
|
retdict[css[0]]["images"].append(css[5])
|
|
|
|
else:
|
|
|
|
retdict[css[0]] = make_css_dict(css)
|
|
|
|
return retdict
|