From: Jason Skomorowski Date: Tue, 11 Jun 2013 18:34:41 +0000 (+0000) Subject: Initial commit X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=f2db386452db9475ca36291fa44c59ee7b043219;p=mkdrusampletheme.git Initial commit --- f2db386452db9475ca36291fa44c59ee7b043219 diff --git a/css/customtheme.css b/css/customtheme.css new file mode 100644 index 0000000..9198573 --- /dev/null +++ b/css/customtheme.css @@ -0,0 +1,75 @@ +.mkdru-result-description { + font-size: 0.8em; +} + +.mkdru-above-below { + font-size: 0.9em; + border: 0; + padding: 0.25em; + font-family: "Lucida Grande","Lucida Sans Unicode",Verdana,sans-serif; +} +.mkdru-above { + border-bottom: 1px solid #D6D6D6; +} +.mkdru-below { + border-top: 1px solid #D6D6D6; + text-align: center; +} + + +.mkdru-result { + padding: .8em 1em 1em 1em !important; + border-bottom: 3px solid #FFFFFF; +/* margin-top: 0 !important; */ +/* margin-bottom: 0 !important; */ +} +.mkdru-result.odd { + background-color: #f6f6f2; +} +.mkdru-result.even { + background-color: #ebebe7; +} +.mkdru-result div { + margin-top: 0; + margin-bottom: .3em; +} +.mkdru-result-author { + margin-left: 1em !important; +} +.mkdru-result-description { + font-family: "Lucida Grande","Lucida Sans Unicode",Verdana,sans-serif; +} + + +.mkdru-search { + text-align: left; +} +.mkdru-search input[type='text'] { + width: 100%; +} +.mkdru-search input[type='submit'] { + margin-left: 12px; +} + + +.mkdru-facet { + font-family: "Lucida Grande","Lucida Sans Unicode",Verdana,sans-serif; +} + + +.mkdru-block-search input.form-text { + margin-right: 5px; + width: 9.5em; +} +.mkdru-block-search input.form-submit { + background: url("../images/search-button.png") no-repeat scroll center top transparent; + border-color: #E4E4E4 #D2D2D2 #B4B4B4; + cursor: pointer; + height: 25px; + margin-left: 0; + margin-right: 0; + overflow: hidden; + padding: 0; + text-indent: -9999px; + width: 34px; +} \ No newline at end of file diff --git a/customtheme.js b/customtheme.js new file mode 100644 index 0000000..9ba1f61 --- /dev/null +++ b/customtheme.js @@ -0,0 +1,88 @@ +Drupal.theme.mkdruCounts = function(first, last, available, total) { + if (last > 0) + return '' + first + '' + Drupal.t(' to ') + '' + last + '' + Drupal.t(' of ') + '' + + available + '' + Drupal.t(' available'); + else + return Drupal.t('No results'); +}; + +Drupal.theme.mkdruResult = function(hit, num, detailLink) { + var resultclass = "mkdru-result "; + if (num%2) + resultclass += "odd"; + else + resultclass += "even"; + var html = ""; + html += '
  • ' + + '
    ' + + hit["md-title"] + ''; + if (hit["md-title-remainder"] !== undefined) { + html += ' ' + + hit["md-title-remainder"] + ' '; + } + html += '
    '; + if (hit["md-title-responsibility"] !== undefined) { + html += '
    ' + + hit["md-title-responsibility"] + + ' '; + if (hit["md-date"] !== undefined) { + html += hit["md-date"]; + } + html += '
    '; + } + if (hit["md-description"] !== undefined) { + // limit description to 400 characters + html += '
    ' + + String(hit["md-description"]).substr(0, 400) + + '
    '; + } + + html += '
  • '; + return html; +}; + +Drupal.theme.mkdruDetail = function(data, linkBack) { + var html = ''; + if (data["md-title"] != undefined) { + html += ''; + } + if (data["md-date"] != undefined) + html += ''; + if (data["md-author"] != undefined) + html += ''; + if (data["md-electronic-url"] != undefined) + html += ''; + // test if there is an array of per-location data; process it + if (Object.prototype.toString.call(data['location']) === '[object Array]') { + var subject = false; + var locations = ""; + for (var i = 0; i < data['location'].length; i++) { + var locRec = data['location'][i]; + // grab the first value we find for subject + if (!subject && locRec['md-subject']) subject = locRec['md-subject']; + // list named locations and link to the record there if url is available + var link = locRec["md-electronic-url"]; + if (!link) link = pz2urlrecipe.getUrlFromRecipe(locRec); + var name = locRec["@name"] + if (link && name) locations += '' + name + '
    '; + else if (name) locations += name + '
    '; + } + if (subject) + html += ''; + if (locations) + html += ''; + } + html += '
    ' + Drupal.t("Title") + '' + + data["md-title"]; + if (data["md-title-remainder"] !== undefined) { + html += ' : ' + data["md-title-remainder"] + ' '; + } + if (data["md-title-responsibility"] !== undefined) { + html += ' '+ data["md-title-responsibility"] +''; + } + html += '
    ' + Drupal.t("Date") + '' + data["md-date"] + '
    ' + Drupal.t("Author") + '' + data["md-author"] + '
    URL' + + data["md-electronic-url"] + '' + '
    ' + Drupal.t("Subject") + '' + subject + '
    ' + Drupal.t("Location") + '' + locations + '
    '; + html += '' + Drupal.t('Return to result list...') + ''; + return html; +}; diff --git a/images/search-button.png b/images/search-button.png new file mode 100644 index 0000000..c6e820a Binary files /dev/null and b/images/search-button.png differ diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..0ada453 Binary files /dev/null and b/logo.png differ diff --git a/mkdrusampletheme.info b/mkdrusampletheme.info new file mode 100644 index 0000000..f07939c --- /dev/null +++ b/mkdrusampletheme.info @@ -0,0 +1,27 @@ +name = MkDru Subtheme Example +description = A demonstration using Drupal theming to customise MkDru. +core = 7.x +base theme = bartik + +stylesheets[all][] = css/customtheme.css + +regions[header] = Header +regions[help] = Help +regions[page_top] = Page top +regions[page_bottom] = Page bottom +regions[highlighted] = Highlighted + +regions[featured] = Featured +regions[content] = Content +regions[sidebar_first] = Sidebar first +regions[sidebar_second] = Sidebar second + +regions[triptych_first] = Triptych first +regions[triptych_middle] = Triptych middle +regions[triptych_last] = Triptych last + +regions[footer_firstcolumn] = Footer first column +regions[footer_secondcolumn] = Footer second column +regions[footer_thirdcolumn] = Footer third column +regions[footer_fourthcolumn] = Footer fourth column +regions[footer] = Footer diff --git a/pz2urlrecipe.js b/pz2urlrecipe.js new file mode 100644 index 0000000..087edb5 --- /dev/null +++ b/pz2urlrecipe.js @@ -0,0 +1,133 @@ +var pz2urlrecipe = (function() { + var choose_url = function (data, proxyPattern) { + //first try to prepare local_url from recipe + var local_url = data["md-url_recipe"] !== undefined + ? prepare_url(data["md-url_recipe"][0], data) : null; + + var use_url_proxy = data["md-use_url_proxy"] !== undefined + ? data["md-use_url_proxy"] : "0"; + + //use the proxyPattern + if (proxyPattern && use_url_proxy == "1") { + if (local_url) { + data["md-local-url"] = []; + data["md-local-url"].push(local_url); + } + var ref_local_url = prepare_url(proxyPattern, data); + if (ref_local_url) return ref_local_url; + } + + // proxyPattern failed, go for local + if (local_url) + return local_url; + + //local failed, go for resource + return data["md-electronic-url"] !== undefined + ? data["md-electronic-url"][0] : null; + } + + var XRef = function (url, text) { + this.url = url; + this.text = text; + }; + + var has_recipe = function (data) { + var has = false; + if (data["md-url_recipe"] !== undefined) { + var recipe = data["md-url_recipe"][0]; + if (typeof recipe == "string" && recipe.length>0) { + has = true; + } + } + return has; + } + + var getUrlFromRecipe = function (data) { + if (has_recipe(data)) { + return prepare_url(data["md-url_recipe"][0],data); + } else { + return null; + } + } + + var getElectronicUrls = function (data) { + var urls = []; + if (data["md-electronic-url"] !== undefined) { + for (var i=0; i0 && regex_str.charAt(j) == '/' && regex_str.charAt(j-1) != '\\') + i++; + else + regex_parts[i] += regex_str.charAt(j); + } + var regex_obj = new RegExp(regex_parts[0], regex_parts[2]); + return input_str.replace(regex_obj, regex_parts[1]); + } + + var test_url_recipe = function () { + var url_recipe = "http://www.indexdata.com/?title=${md-title[\\s+/+/g]}&author=${md-author}"; + var meta_data = { "md-title" : ["Art of Computer Programming"], "md-author" : ["Knuth"]} + var final_url = prepare_url(url_recipe, meta_data); + alert(final_url); + } + + // expose public methods + return { + getUrlFromRecipe: getUrlFromRecipe, + getElectronicUrls: getElectronicUrls, + }; +})(); diff --git a/template.php b/template.php new file mode 100644 index 0000000..7ad3a78 --- /dev/null +++ b/template.php @@ -0,0 +1,11 @@ +type == 'mkdru')) { + # helper functions to apply URL recipes + drupal_add_js(drupal_get_path('theme', 'mkdrusampletheme') . '/pz2urlrecipe.js'); + drupal_add_js(drupal_get_path('theme', 'mkdrusampletheme') . '/customtheme.js'); + } +} + diff --git a/templates/mkdru-block-facet.tpl.php b/templates/mkdru-block-facet.tpl.php new file mode 100644 index 0000000..c32aed9 --- /dev/null +++ b/templates/mkdru-block-facet.tpl.php @@ -0,0 +1 @@ +
    diff --git a/templates/mkdru-block-search.tpl.php b/templates/mkdru-block-search.tpl.php new file mode 100644 index 0000000..17ef61d --- /dev/null +++ b/templates/mkdru-block-search.tpl.php @@ -0,0 +1,4 @@ + diff --git a/templates/mkdru-form.tpl.php b/templates/mkdru-form.tpl.php new file mode 100644 index 0000000..aaddba3 --- /dev/null +++ b/templates/mkdru-form.tpl.php @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/templates/mkdru-results.tpl.php b/templates/mkdru-results.tpl.php new file mode 100644 index 0000000..f187c59 --- /dev/null +++ b/templates/mkdru-results.tpl.php @@ -0,0 +1,6 @@ +
    +
    +
    +
      +
      +