current state (very incomplete)

This commit is contained in:
Olivier Berten 2013-02-24 20:23:59 +01:00
parent 36a2cb8569
commit ce9d672287
24 changed files with 13090 additions and 0 deletions

41
booklets.php Normal file
View File

@ -0,0 +1,41 @@
<?php
include('include/db.php');
$title = 'Booklets';
include('include/header.php');
echo "<h2>$title</h2>\n";
$sql1 = 'SELECT * FROM '.$db['booklets'].' ORDER BY filename';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
echo "<ul class=\"incipit\">\n";
while($b = $req1->fetch_assoc()) {
echo '<li>'.$b['title']; //<tt>'.$b['id'].'</tt>
echo ' <span class="version">('.$b['filename'].")</span><ul>";
$c = json_decode($b['content'],true);
foreach($c as $l) {
if($l[0] == 'score') {
if(is_int($l[1])) {
$t = chant_from_id($l[1]);
$e = array($t[0],'<a href="chant.php?id='.$l[1].'">'.format_incipit($t[1]).'</a> <span class="version">('.$t[3].')</span>');
if(array_key_exists("annotation_prefix",$l[2])) {
$e[1] = $l[2]["annotation_prefix"].' '.$e[1];
}
} elseif(is_string($l[1])) {
$e = $l[1];
} elseif(is_array($l[1])) {
}
} elseif($l[0] == 'tex') {
$e = '<tt>'.$l[1].'</tt>';
}
if(is_array($e)) {
echo '<li class="usage-marker '.$e[0].'">'.$e[1]."</li>\n";
} else {
echo "<li>$e</li>\n";
}
}
echo "</ul></li>\n";
}
echo "</ul>\n";
include('include/footer.php');
?>

30
changes.php Normal file
View File

@ -0,0 +1,30 @@
<?php
include('include/db.php');
include('include/finediff.php');
$title = 'Changesets';
include('include/header.php');
echo "<h2>$title</h2>\n";
$sql1 = 'SELECT * FROM '.$db['changesets'].' WHERE time > 1357000000 ORDER BY time DESC';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
while($m = $req1->fetch_assoc()) {
echo "<h4>".date("M d, Y",$m['time'])." (".username_from_id($m['user_id']).")</h4>\n";
echo "<p>".$m['comment']."</p>\n";
$sql3 = 'SELECT * FROM '.$db['chants'].' WHERE id = '.$m['chant_id'];
$req3 = $mysqli->query($sql3) or die('Erreur SQL !<br />'.$sql3.'<br />'.$mysqli->error);
$c = $req3->fetch_assoc();
$sql2 = 'SELECT * FROM '.$db['changes'].' WHERE changeset = "'.$m['user_id'].'|'.$m['chant_id'].'|'.$m['time'].'" ORDER BY field';
$req2 = $mysqli->query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.$mysqli->error);
while($f = $req2->fetch_assoc()) {
echo '<p><i>'.$f['field']."</i><br />\n";
$from_text = $f['changed'];
$to_text = $c[$f['field']];
$diff = new FineDiff($from_text, $to_text, FineDiff::$wordGranularity);
$opcodes = FineDiff::getDiffOpcodes($from_text, $to_text);
echo '<tt>'.FineDiff::renderDiffToHTMLFromOpcodes($from_text, $opcodes)."</tt></p>\n";
}
}
echo "</ul>\n";
include('include/footer.php');
?>

154
chant.php Normal file
View File

@ -0,0 +1,154 @@
<?php
include('include/db.php');
include('include/txt.php');
include('include/sources.php');
if(array_key_exists("id", $_GET)) {
$id = intval($_GET['id']);
} else {
die('No id');
}
$sql1 = 'SELECT * FROM '.$db['chants'].' WHERE id = '.$id;
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$c = $req1->fetch_assoc();
if(!$c) {
die('Wrong id');
}
$title = $c['incipit'];
include('include/header.php');
if(isset($_POST['proofread']) && $_POST['proofread'] == 'Me' && $c) {
$mysqli->query('INSERT into '.$db['proofreading'].' VALUES ('.$id.','.$current_user->ID.','.time().')') or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
}
$c_p = array();
$sql1 = 'SELECT * FROM '.$db['chant_sources'].' WHERE chant_id = '.$id.' ORDER BY source';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
while ($s = $req1->fetch_assoc()) {
$c_s = array($s['source'], $s['page']);
if(is_dir('./sources/'.$s['source'])) {
if(is_array($sources[$s['source']]['pages'])) {
$p = array_search($s['page'],$sources[$s['source']]['pages']);
} else {
$p = $s['page'];
}
$c_p[] = array($s['source'], $s['page'], $p, $s['extent']);
} else {
$c_p[] = $c_s;
}
}
echo '<div id="score"><br />';
if($c['gabc'] > '') {
echo '<img src="scores/'.$id.'.png" alt="" />';
} else {
if($logged_in != true) {
echo 'Yet to be transcribed. Please log-in or register if you would like to do it.';
}
}
echo '<br />&nbsp;</div>'."\n";
echo '<div id="info">
';
echo '<h3>'.format_incipit($c['incipit']);
if($logged_in) {
echo ' <span class="edit"><a href="chant_edit.php?id='.$id.'">Edit</a></span>';
}
echo '</h3>
<h4>Version</h4><ul><li>'.$c['version']."</li></ul>\n";
echo '<h4>Usage</h4><ul><li><span class="usage '.$c['office-part'].'">'.$txt['usage'][$c['office-part']]."</span></li></ul>\n";
$sources_img = "";
if(count($c_p) > 0) {
echo "<h4>Sources</h4>\n<ul>\n";
$cnt = 1;
foreach($c_p as $s) {
$source_label = "<i>".$sources[$s[0]]['title'].", ".$sources[$s[0]]['editor'].", ".$sources[$s[0]]['year']."</i>, p. ".$s[1];
if (count($s) > 2) {
echo '<li><a href="#source_'.$cnt.'">'.$source_label."</a></li>\n";
$sources_img .= '<p><a name="source_'.$cnt.'">'.$source_label."</a><br />\n";
for($i = 0; $i < $s[3]; $i++) {
$sources_img .= '<img src="sources/'.$s[0].'/'.($s[2]+$i).'.png" alt="" /><br />'."\n";
}
$sources_img .= "</p>\n<hr />\n";
} else {
echo "<li>".$source_label."</li>\n";
}
$cnt += 1;
}
echo "</ul>\n";
}
$sql1 = 'SELECT * FROM '.$db['proofreading'].' WHERE chant_id = '.$c['id'].' ORDER BY time DESC';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$proof = array();
$proof_done = False;
while ($r = $req1->fetch_assoc()) {
$proof[] = $r;
if($logged_in && $r['user_id'] == $current_user->ID) $proof_done = True;
}
if(count($proof) > 0 || $logged_in) {
echo "<h4>Proofread by:</h4>\n<ul>\n";
}
if($logged_in && !$proof_done) {
echo '<li><form action="'.$_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:'').'" method="post"><input type="submit" name="proofread" value="Me" /></form></li>'."\n";
}
foreach($proof as $r) {
$user_info = get_userdata($r['user_id']);
echo "<li>".$user_info->display_name." (".date("M d, Y",$r['time']).")</li>\n";
}
if(count($proof) > 0 || $logged_in) {
echo "</ul>\n";
}
echo "<h4>Download</h4>\n<ul>\n";
$content = json_decode($c['gabc']);
if(is_string($content)) {
echo '<li><a href="download.php?id='.$c['id'].'&amp;format=gabc">GABC</a></li>'."\n";
} elseif(is_array($content)) {
$gabcs = array();
foreach($content as $e) {
if($e[0] == 'score') $gabcs[] = $e[1];
}
echo "<li>GABC<ul>";
for($i = 0; $i < count($gabcs); $i++) {
echo '<li><a href="download.php?id='.$c['id'].'&amp;format=gabc&amp;elem='.($i+1).'">Element '.($i+1)."</a></li>\n";
}
echo "</ul></li>\n";
}
echo '<li><a href="download.php?id='.$c['id'].'&amp;format=pdf">PDF</a></li>'."\n";
echo '<li><a href="download.php?id='.$c['id'].'&amp;format=eps">EPS</a></li>'."\n";
echo '<li><a href="download.php?id='.$c['id'].'&amp;format=png">PNG</a></li>'."\n";
echo "</ul>\n";
if($c['gabc_verses'] || $c['tex_verses']){
echo "<ul>\n";
echo '<li><a href="download.php?id='.$c['id'].'&amp;format=gabc&amp;1verse=1">GABC (1st verse)</a></li>'."\n";
echo '<li><a href="download.php?id='.$c['id'].'&amp;format=pdf&amp;1verse=1">PDF (1st verse)</a></li>'."\n";
echo '<li><a href="download.php?id='.$c['id'].'&amp;format=eps&amp;1verse=1">EPS (1st verse)</a></li>'."\n";
echo '<li><a href="download.php?id='.$c['id'].'&amp;format=png&amp;1verse=1">PNG (1st verse)</a></li>'."\n";
echo "</ul>\n";
}
$sql1 = 'SELECT * FROM '.$db['changesets'].' WHERE chant_id = '.$c['id'].' ORDER BY time DESC';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
if($req1->num_rows > 0 || $c['transcriber'] > '') {
echo "<h4>History</h4>\n<ul>\n";
}
while ($m = $req1->fetch_assoc()) {
$user_info = get_userdata($m['user_id']);
echo "<li>".date("M d, Y",$m['time']).": ".$m['comment']." (".$user_info->display_name.")</li>\n";
}
if($c['transcriber'] > '') {
echo "<li>Original transcriber: ".$c['transcriber']."</li>\n";
}
if($req1->num_rows > 0 || $c['transcriber'] > '') {
echo "</ul>\n";
}
echo "<hr />\n";
echo $sources_img;
echo '</div>';
include('include/footer.php');
?>

94
chant_edit.php Normal file
View File

@ -0,0 +1,94 @@
<?php
include('include/db.php');
include('include/txt.php');
include('include/sources.php');
if(array_key_exists("id", $_GET)) {
$id = intval($_GET['id']);
} else {
die('No id');
}
$sql1 = 'SELECT * FROM '.$db['chants'].' WHERE id = '.$id;
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$c = $req1->fetch_assoc();
if(!$c) {
die('Wrong id');
}
$title = $c['incipit'];
include('include/header.php');
if(!$logged_in) {
echo "Please login";
} elseif(count($_POST) > 0) {
#$mysqli->query('INSERT into '.$db['proofreading'].' VALUES ('.$id.','.$_SESSION['user_id'].','.time().')') or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
} else {
$c_p = array();
$sql1 = 'SELECT * FROM '.$db['chant_sources'].' WHERE chant_id = '.$id;
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
while ($s = $req1->fetch_assoc()) {
$c_s = array($s['source'], $s['page']);
if(is_dir('./sources/'.$s['source'])) {
if(is_array($sources[$s['source']]['pages'])) {
$p = array_search($s['page'],$sources[$s['source']]['pages']);
} else {
$p = $s['page'];
}
$c_p[] = array($s['source'], $s['page'], $p, $s['extent']);
} else {
$c_p[] = $c_s;
}
}
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
echo '<div id="score"><br />';
echo '<h4>Mode</h4><input name="annotation1" value="'.$c['mode'].'" size="3" /><input name="annotation2" value="'.$c['mode_var'].'" size="3" /><br />';
echo '<h4>Initial style<select name="office-part">';
echo '<option value="0">No initial</option>'."\n";
echo '<option value="1" selected>1-line initial</option>'."\n";
echo '<option value="2">2-lines initial</option>'."\n";
echo "</select>\n";
echo '<h4>GABC</h4><textarea name="gabc" id="gabc">'.($c['gabc']>''?$c['gabc']:'(c4)').'</textarea>';
echo '<br />&nbsp;</div>'."\n";
echo '<div id="info">
';
echo '<h4>Incipit</h4><input name="incipit" value="'.$c['incipit'].'" />
<h4>Usage</h4><select name="office-part">';
foreach($txt['usage'] as $k => $v) {
echo '<option value="'.$k.'"'.($c['office-part']==$k?' selected':'').'>'.$v.'</option>'."\n";
}
echo "</select>\n";
echo '<h4>Original transcriber</h4><input name="transcriber" value="'.$c['transcriber'].'" />';
$sources_img = "";
if(count($c_p) > 0) {
echo "<h4>Sources</h4>\n<ul>\n";
$cnt = 1;
foreach($c_p as $s) {
$source_label = "<i>".$sources[$s[0]]['title'].", ".$sources[$s[0]]['year']."</i>, p. ".$s[1];
if (count($s) > 2) {
echo '<li><a href="#source_'.$cnt.'">'.$source_label."</a></li>\n";
$sources_img .= '<p><a name="source_'.$cnt.'">'.$source_label."</a><br />\n";
for($i = 0; $i < $s[3]; $i++) {
$sources_img .= '<img src="sources/'.$s[0].'/'.($s[2]+$i).'.png" alt="" /><br />'."\n";
}
$sources_img .= "</p>\n<hr />\n";
} else {
echo "<li>".$source_label."</li>\n";
}
$cnt += 1;
}
echo "</ul>\n";
}
echo "<hr />\n";
echo $sources_img;
echo "</div>\n";
echo "</form>\n";
}
include('include/footer.php');
?>

106
download.php Normal file
View File

@ -0,0 +1,106 @@
<?php
include('include/db.php');
include('include/txt.php');
include('include/sources.php');
if(array_key_exists('id', $_GET)) {
$id = intval($_GET['id']);
} else {
die('No id');
}
if(array_key_exists('1verse', $_GET) && $_GET['1verse'] == '1') {
$suffix = ".1verse";
} else {
$suffix = "";
}
$sql1 = 'SELECT * FROM '.$db['chants'].' WHERE id = '.$id;
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$c = $req1->fetch_assoc();
if(!$c) {
die('Wrong id');
}
function cleanString($string) {
$string = str_replace('Æ','ae', $string);
$string = str_replace('æ','ae', $string);
$string = str_replace('œ','oe', $string);
$string = preg_replace("/[^a-z\d-_ ]/i","", $string);
$string = str_replace(" ","_", trim($string));
$string = strtolower($string);
return $string;
}
$formats = array('png' => 'image/png', 'pdf' => 'application/pdf', 'eps' => 'image/x-eps');
if(array_key_exists('format', $_GET)) {
$f = $_GET['format'];
$filename = cleanString($c['office-part'].'--'.$c['incipit'].'-- '.$c['version']);
if($f == 'gabc') {
$content = json_decode($c['gabc']);
if(is_string($content)) {
$gabc = $content;
} elseif(is_array($content)) {
$gabcs = array();
foreach($content as $e) {
if($e[0] == 'score') $gabcs[] = $e[1];
}
if(array_key_exists('elem', $_GET) && (int)$_GET['elem'] < count($gabcs)+1) {
$gabc = $gabcs[(int)$_GET['elem']-1];
$suffix = '.'.$_GET['elem'];
} else {
die();
}
}
$c_p = array();
$sql1 = 'SELECT * FROM '.$db['chant_sources'].' WHERE chant_id = '.$id;
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
while ($s = $req1->fetch_assoc()) {
$c_p[] = array($s['source'], $s['page']);
}
header('Content-Type:text/plain; charset=UTF-8');
header('Content-Disposition: attachment; filename='.$filename.$suffix.'.'.'gabc');
echo "name:".$c['incipit'].";\n";
if($c['annotation1'] > ''){
echo "annotation:".$c['annotation1'].";\n";
}
if($c['annotation2'] > ''){
echo "annotation:".$c['annotation2'].";\n";
}
if($c['office-part'] > ''){
echo "office-part:".$txt['usage'][$c['office-part']].";\n";
}
if($c['mode'] > ''){
echo "mode:".$c['mode'].";\n";
}
if(count($c_p) > 0) {
echo "book:";
$source_label = '';
foreach($c_p as $s) {
$source_label .= $sources[$s[0]]['title'].", ".$sources[$s[0]]['year'].", p. ".$s[1].' & ';
}
echo substr($source_label, 0, strlen($source_label)-3).";\n";
}
if($c['transcriber'] > ''){
echo "transcriber:".$c['transcriber'].";\n";
}
if($c['commentary'] > ''){
echo "commentary:".$c['commentary'].";\n";
}
echo "%%\n";
echo $gabc;
if($c['gabc_verses'] && !($suffix > "")) {
echo "\n".$c['gabc_verses'];
}
} elseif(in_array($f, array_keys($formats))) {
header('Content-Type:'.$formats[$f]);
header('Content-Disposition: attachment; filename='.$filename.$suffix.'.'.$f);
echo(file_get_contents('scores/'.$f.'/'.$id.$suffix.'.'.$f));
} else {
die('Unknown format');
}
}

10123
grego_online.sql Normal file

File diff suppressed because one or more lines are too long

36
history.php Normal file
View File

@ -0,0 +1,36 @@
<?php
include('include/db.php');
include('include/finediff.php');
if(array_key_exists("id", $_GET)) {
$id = intval($_GET['id']);
} else {
die('No id');
}
$sql1 = 'SELECT * FROM '.$db['chants'].' WHERE id = '.$id;
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$c = $req1->fetch_assoc();
$title = 'History - '.$c['incipit'];
include('include/header.php');
echo "<h2>$title</h2>\n";
$sql1 = 'SELECT * FROM '.$db['changesets'].' WHERE chant_id = '.$id.' ORDER BY time DESC';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
while($m = $req1->fetch_assoc()) {
echo "<h4>".date("M d, Y",$m['time'])." (".username_from_id($m['user_id']).")</h4>\n";
echo "<p>".$m['comment']."</p>\n";
$sql2 = 'SELECT * FROM '.$db['changes'].' WHERE changeset = "'.$m['user_id'].'|'.$id.'|'.$m['time'].'" ORDER BY field';
$req2 = $mysqli->query($sql2) or die('Erreur SQL !<br />'.$sql2.'<br />'.$mysqli->error);
while($f = $req2->fetch_assoc()) {
echo '<p><i>'.$f['field']."</i><br />\n";
$from_text = $f['changed'];
$to_text = $c[$f['field']];
$diff = new FineDiff($from_text, $to_text, FineDiff::$wordGranularity);
$opcodes = FineDiff::getDiffOpcodes($from_text, $to_text);
echo '<tt>'.FineDiff::renderDiffToHTMLFromOpcodes($from_text, $opcodes)."</tt></p>\n";
}
}
echo "</ul>\n";
include('include/footer.php');
?>

39
incipit.php Normal file
View File

@ -0,0 +1,39 @@
<?php
include('include/db.php');
if(array_key_exists("letter", $_GET)) {
$l = $mysqli->real_escape_string($_GET['letter']);
} else {
die('No letter');
}
$title = 'Incipit - '.$l;
include('include/header.php');
echo "<h2>$title</h2>\n";
if($l) {
$sql1 = 'SELECT * FROM '.$db['chants'].' WHERE `incipit` LIKE "'.$l.'%" ORDER BY incipit ASC';
} else {
$sql1 = 'SELECT * FROM '.$db['chants'].' WHERE `incipit` LIKE "" ORDER BY incipit ASC';
}
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$chants = array();
while($c = $req1->fetch_assoc()) {
$chants[] = $c;
}
if(count($chants)) {
usort($chants, "custom_cmp");
}
echo "<ul class=\"incipit\">\n";
foreach($chants as $c) {
$incipit = $c['incipit']?format_incipit($c['incipit']):"===";
echo '<li class="usage-marker '.$c['office-part'].'">';
if($c['gabc'] > '') {
echo '<a href="chant.php?id='.$c['id'].'">'.$incipit."</a>";
} else {
echo '<span class="todo">'.$incipit.'</span>';
}
echo ' <span class="version">('.$c['version'].")</span></li>\n";
}
echo "</ul>\n";
include('include/footer.php');
?>

40
include/db.php Normal file
View File

@ -0,0 +1,40 @@
<?php
function chant_from_id($c) {
global $db,$mysqli;
$sql1 = 'SELECT `office-part`,incipit,gabc,version FROM '.$db['chants'].' WHERE id = '.$c;
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$chants = array();
$ch = $req1->fetch_assoc();
return array($ch['office-part'], $ch['incipit'], $ch['gabc'] > '', $ch['version']);
}
define("HOST", ""); // The host you want to connect to.
define("USER", ""); // The database username.
define("PASSWORD", ""); // The database password.
define("DATABASE", ""); // The database name.
$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
$mysqli->query('SET NAMES utf8');
function db($s) {
$db_prefix = 'gregobase_';
return $db_prefix.$s;
}
$db_prefix = 'gregobase_';
$db = array('booklets' => $db_prefix.'booklets',
'chants' => $db_prefix.'chants',
'chant_sources' => $db_prefix.'chant_sources',
'sources' => $db_prefix.'sources',
'changes' => $db_prefix.'changes',
'changesets' => $db_prefix.'changesets',
'users' => $db_prefix.'users',
'proofreading' => $db_prefix.'proofreading');
require_once('./wp-blog-header.php');
$current_user = wp_get_current_user();
$logged_in = is_user_logged_in();
?>

759
include/finediff.php Normal file
View File

@ -0,0 +1,759 @@
<?php
/**
* FINE granularity DIFF
*
* Computes a set of instructions to convert the content of
* one string into another.
*
* Copyright (c) 2011 Raymond Hill (http://raymondhill.net/blog/?p=441)
*
* Licensed under The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @copyright Copyright 2011 (c) Raymond Hill (http://raymondhill.net/blog/?p=441)
* @link http://www.raymondhill.net/finediff/
* @version 0.6
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*
* 10-Dec-2011 (Christoph Mewes):
* - added UTF-8 support, fixed strange usage of htmlentities
*
* 15-Mar-2012 (Marek Lichtner):
* - improved html renderer
*
* 17-Jul-2012(Brandon Frohs):
* - added __toString() method
*/
mb_internal_encoding('UTF-8');
/**
* Usage (simplest):
*
* include 'finediff.php';
*
* // for the stock stack, granularity values are:
* // FineDiff::$paragraphGranularity = paragraph/line level
* // FineDiff::$sentenceGranularity = sentence level
* // FineDiff::$wordGranularity = word level
* // FineDiff::$characterGranularity = character level [default]
*
* $opcodes = FineDiff::getDiffOpcodes($from_text, $to_text [, $granularityStack = null] );
* // store opcodes for later use...
*
* ...
*
* // restore $to_text from $from_text + $opcodes
* include 'finediff.php';
* $to_text = FineDiff::renderToTextFromOpcodes($from_text, $opcodes);
*
* ...
*/
/**
* Persisted opcodes (string) are a sequence of atomic opcode.
* A single opcode can be one of the following:
* c | c{n} | d | d{n} | i:{c} | i{length}:{s}
* 'c' = copy one character from source
* 'c{n}' = copy n characters from source
* 'd' = skip one character from source
* 'd{n}' = skip n characters from source
* 'i:{c} = insert character 'c'
* 'i{n}:{s}' = insert string s, which is of length n
*
* Do not exist as of now, under consideration:
* 'm{n}:{o} = move n characters from source o characters ahead.
* It would be essentially a shortcut for a delete->copy->insert
* command (swap) for when the inserted segment is exactly the same
* as the deleted one, and with only a copy operation in between.
* TODO: How often this case occurs? Is it worth it? Can only
* be done as a postprocessing method (->optimize()?)
*/
abstract class FineDiffOp {
abstract public function getFromLen();
abstract public function getToLen();
abstract public function getOpcode();
}
class FineDiffDeleteOp extends FineDiffOp {
public function __construct($len) {
$this->fromLen = $len;
}
public function getFromLen() {
return $this->fromLen;
}
public function getToLen() {
return 0;
}
public function getOpcode() {
if ( $this->fromLen === 1 ) {
return 'd';
}
return "d{$this->fromLen}";
}
}
class FineDiffInsertOp extends FineDiffOp {
public function __construct($text) {
$this->text = $text;
}
public function getFromLen() {
return 0;
}
public function getToLen() {
return mb_strlen($this->text);
}
public function getText() {
return $this->text;
}
public function getOpcode() {
$to_len = mb_strlen($this->text);
if ( $to_len === 1 ) {
return "i:{$this->text}";
}
return "i{$to_len}:{$this->text}";
}
}
class FineDiffReplaceOp extends FineDiffOp {
public function __construct($fromLen, $text) {
$this->fromLen = $fromLen;
$this->text = $text;
}
public function getFromLen() {
return $this->fromLen;
}
public function getToLen() {
return mb_strlen($this->text);
}
public function getText() {
return $this->text;
}
public function getOpcode() {
if ( $this->fromLen === 1 ) {
$del_opcode = 'd';
}
else {
$del_opcode = "d{$this->fromLen}";
}
$to_len = mb_strlen($this->text);
if ( $to_len === 1 ) {
return "{$del_opcode}i:{$this->text}";
}
return "{$del_opcode}i{$to_len}:{$this->text}";
}
}
class FineDiffCopyOp extends FineDiffOp {
public function __construct($len) {
$this->len = $len;
}
public function getFromLen() {
return $this->len;
}
public function getToLen() {
return $this->len;
}
public function getOpcode() {
if ( $this->len === 1 ) {
return 'c';
}
return "c{$this->len}";
}
public function increase($size) {
return $this->len += $size;
}
}
/**
* FineDiff ops
*
* Collection of ops
*/
class FineDiffOps {
public $edits = array();
public function appendOpcode($opcode, $from, $from_offset, $from_len) {
if ( $opcode === 'c' ) {
$edits[] = new FineDiffCopyOp($from_len);
}
else if ( $opcode === 'd' ) {
$edits[] = new FineDiffDeleteOp($from_len);
}
else /* if ( $opcode === 'i' ) */ {
$edits[] = new FineDiffInsertOp(mb_substr($from, $from_offset, $from_len));
}
}
}
/**
* FineDiff class
*
* TODO: Document
*
*/
class FineDiff {
/**------------------------------------------------------------------------
*
* Public section
*
*/
/**
* Constructor
* ...
* The $granularityStack allows FineDiff to be configurable so that
* a particular stack tailored to the specific content of a document can
* be passed.
*/
public function __construct($from_text = '', $to_text = '', $granularityStack = null) {
// setup stack for generic text documents by default
$this->granularityStack = $granularityStack ? $granularityStack : FineDiff::$characterGranularity;
$this->edits = array();
$this->from_text = $from_text;
$this->doDiff($from_text, $to_text);
}
/**
* Magic __toString() method
* ...
* Assuming `$diff = new FineDiff($from, $to);`, `echo $diff` will print the HTML diff.
*/
public function __toString(){
return $this->renderDiffToHTML();
}
public function getOps() {
return $this->edits;
}
public function getOpcodes() {
$opcodes = array();
foreach ( $this->edits as $edit ) {
$opcodes[] = $edit->getOpcode();
}
return implode('', $opcodes);
}
public function renderDiffToHTML() {
$in_offset = 0;
ob_start();
foreach ( $this->edits as $edit ) {
$n = $edit->getFromLen();
if ( $edit instanceof FineDiffCopyOp ) {
FineDiff::renderDiffToHTMLFromOpcode('c', $this->from_text, $in_offset, $n);
}
else if ( $edit instanceof FineDiffDeleteOp ) {
FineDiff::renderDiffToHTMLFromOpcode('d', $this->from_text, $in_offset, $n);
}
else if ( $edit instanceof FineDiffInsertOp ) {
FineDiff::renderDiffToHTMLFromOpcode('i', $edit->getText(), 0, $edit->getToLen());
}
else /* if ( $edit instanceof FineDiffReplaceOp ) */ {
FineDiff::renderDiffToHTMLFromOpcode('d', $this->from_text, $in_offset, $n);
FineDiff::renderDiffToHTMLFromOpcode('i', $edit->getText(), 0, $edit->getToLen());
}
$in_offset += $n;
}
return ob_get_clean();
}
/**------------------------------------------------------------------------
* Return an opcodes string describing the diff between a "From" and a
* "To" string
*/
public static function getDiffOpcodes($from, $to, $granularities = null) {
$diff = new FineDiff($from, $to, $granularities);
return $diff->getOpcodes();
}
/**------------------------------------------------------------------------
* Return an iterable collection of diff ops from an opcodes string
*/
public static function getDiffOpsFromOpcodes($opcodes) {
$diffops = new FineDiffOps();
FineDiff::renderFromOpcodes(null, $opcodes, array($diffops,'appendOpcode'));
return $diffops->edits;
}
/**------------------------------------------------------------------------
* Re-create the "To" string from the "From" string and an "Opcodes" string
*/
public static function renderToTextFromOpcodes($from, $opcodes) {
ob_start();
FineDiff::renderFromOpcodes($from, $opcodes, array('FineDiff','renderToTextFromOpcode'));
return ob_get_clean();
}
/**------------------------------------------------------------------------
* Render the diff to an HTML string
*/
public static function renderDiffToHTMLFromOpcodes($from, $opcodes) {
ob_start();
FineDiff::renderFromOpcodes($from, $opcodes, array('FineDiff','renderDiffToHTMLFromOpcode'));
return ob_get_clean();
}
/**------------------------------------------------------------------------
* Generic opcodes parser, user must supply callback for handling
* single opcode
*/
public static function renderFromOpcodes($from, $opcodes, $callback) {
if ( !is_callable($callback) ) {
return;
}
$opcodes_len = mb_strlen($opcodes);
$from_offset = $opcodes_offset = 0;
while ( $opcodes_offset < $opcodes_len ) {
$opcode = mb_substr($opcodes, $opcodes_offset, 1);
$opcodes_offset++;
$n = intval(mb_substr($opcodes, $opcodes_offset));
if ( $n ) {
$opcodes_offset += mb_strlen(strval($n));
}
else {
$n = 1;
}
if ( $opcode === 'c' ) { // copy n characters from source
call_user_func($callback, 'c', $from, $from_offset, $n, '');
$from_offset += $n;
}
else if ( $opcode === 'd' ) { // delete n characters from source
call_user_func($callback, 'd', $from, $from_offset, $n, '');
$from_offset += $n;
}
else /* if ( $opcode === 'i' ) */ { // insert n characters from opcodes
call_user_func($callback, 'i', $opcodes, $opcodes_offset + 1, $n);
$opcodes_offset += 1 + $n;
}
}
}
/**
* Stock granularity stacks and delimiters
*/
const paragraphDelimiters = "\n\r";
public static $paragraphGranularity = array(
FineDiff::paragraphDelimiters
);
const sentenceDelimiters = ".\n\r";
public static $sentenceGranularity = array(
FineDiff::paragraphDelimiters,
FineDiff::sentenceDelimiters
);
const wordDelimiters = " \t.,;\n\r";
public static $wordGranularity = array(
FineDiff::paragraphDelimiters,
FineDiff::sentenceDelimiters,
FineDiff::wordDelimiters
);
const characterDelimiters = "";
public static $characterGranularity = array(
FineDiff::paragraphDelimiters,
FineDiff::sentenceDelimiters,
FineDiff::wordDelimiters,
FineDiff::characterDelimiters
);
public static $textStack = array(
".",
" \t.\n\r",
""
);
/**------------------------------------------------------------------------
*
* Private section
*
*/
/**
* Entry point to compute the diff.
*/
private function doDiff($from_text, $to_text) {
$this->last_edit = false;
$this->stackpointer = 0;
$this->from_text = $from_text;
$this->from_offset = 0;
// can't diff without at least one granularity specifier
if ( empty($this->granularityStack) ) {
return;
}
$this->_processGranularity($from_text, $to_text);
}
/**
* This is the recursive function which is responsible for
* handling/increasing granularity.
*
* Incrementally increasing the granularity is key to compute the
* overall diff in a very efficient way.
*/
private function _processGranularity($from_segment, $to_segment) {
$delimiters = $this->granularityStack[$this->stackpointer++];
$has_next_stage = $this->stackpointer < count($this->granularityStack);
foreach ( FineDiff::doFragmentDiff($from_segment, $to_segment, $delimiters) as $fragment_edit ) {
// increase granularity
if ( $fragment_edit instanceof FineDiffReplaceOp && $has_next_stage ) {
$this->_processGranularity(
mb_substr($this->from_text, $this->from_offset, $fragment_edit->getFromLen()),
$fragment_edit->getText()
);
}
// fuse copy ops whenever possible
else if ( $fragment_edit instanceof FineDiffCopyOp && $this->last_edit instanceof FineDiffCopyOp ) {
$this->edits[count($this->edits)-1]->increase($fragment_edit->getFromLen());
$this->from_offset += $fragment_edit->getFromLen();
}
else {
/* $fragment_edit instanceof FineDiffCopyOp */
/* $fragment_edit instanceof FineDiffDeleteOp */
/* $fragment_edit instanceof FineDiffInsertOp */
$this->edits[] = $this->last_edit = $fragment_edit;
$this->from_offset += $fragment_edit->getFromLen();
}
}
$this->stackpointer--;
}
/**
* This is the core algorithm which actually perform the diff itself,
* fragmenting the strings as per specified delimiters.
*
* This function is naturally recursive, however for performance purpose
* a local job queue is used instead of outright recursivity.
*/
private static function doFragmentDiff($from_text, $to_text, $delimiters) {
// Empty delimiter means character-level diffing.
// In such case, use code path optimized for character-level
// diffing.
if ( empty($delimiters) ) {
return FineDiff::doCharDiff($from_text, $to_text);
}
$result = array();
// fragment-level diffing
$from_text_len = mb_strlen($from_text);
$to_text_len = mb_strlen($to_text);
$from_fragments = FineDiff::extractFragments($from_text, $delimiters);
$to_fragments = FineDiff::extractFragments($to_text, $delimiters);
$jobs = array(array(0, $from_text_len, 0, $to_text_len));
$cached_array_keys = array();
while ( $job = array_pop($jobs) ) {
// get the segments which must be diff'ed
list($from_segment_start, $from_segment_end, $to_segment_start, $to_segment_end) = $job;
// catch easy cases first
$from_segment_length = $from_segment_end - $from_segment_start;
$to_segment_length = $to_segment_end - $to_segment_start;
if ( !$from_segment_length || !$to_segment_length ) {
if ( $from_segment_length ) {
$result[$from_segment_start * 4] = new FineDiffDeleteOp($from_segment_length);
}
else if ( $to_segment_length ) {
$result[$from_segment_start * 4 + 1] = new FineDiffInsertOp(mb_substr($to_text, $to_segment_start, $to_segment_length));
}
continue;
}
// find longest copy operation for the current segments
$best_copy_length = 0;
$from_base_fragment_index = $from_segment_start;
$cached_array_keys_for_current_segment = array();
while ( $from_base_fragment_index < $from_segment_end ) {
$from_base_fragment = $from_fragments[$from_base_fragment_index];
$from_base_fragment_length = mb_strlen($from_base_fragment);
// performance boost: cache array keys
if ( !isset($cached_array_keys_for_current_segment[$from_base_fragment]) ) {
if ( !isset($cached_array_keys[$from_base_fragment]) ) {
$to_all_fragment_indices = $cached_array_keys[$from_base_fragment] = array_keys($to_fragments, $from_base_fragment, true);
}
else {
$to_all_fragment_indices = $cached_array_keys[$from_base_fragment];
}
// get only indices which falls within current segment
if ( $to_segment_start > 0 || $to_segment_end < $to_text_len ) {
$to_fragment_indices = array();
foreach ( $to_all_fragment_indices as $to_fragment_index ) {
if ( $to_fragment_index < $to_segment_start ) { continue; }
if ( $to_fragment_index >= $to_segment_end ) { break; }
$to_fragment_indices[] = $to_fragment_index;
}
$cached_array_keys_for_current_segment[$from_base_fragment] = $to_fragment_indices;
}
else {
$to_fragment_indices = $to_all_fragment_indices;
}
}
else {
$to_fragment_indices = $cached_array_keys_for_current_segment[$from_base_fragment];
}
// iterate through collected indices
foreach ( $to_fragment_indices as $to_base_fragment_index ) {
$fragment_index_offset = $from_base_fragment_length;
// iterate until no more match
for (;;) {
$fragment_from_index = $from_base_fragment_index + $fragment_index_offset;
if ( $fragment_from_index >= $from_segment_end ) {
break;
}
$fragment_to_index = $to_base_fragment_index + $fragment_index_offset;
if ( $fragment_to_index >= $to_segment_end ) {
break;
}
if ( $from_fragments[$fragment_from_index] !== $to_fragments[$fragment_to_index] ) {
break;
}
$fragment_length = mb_strlen($from_fragments[$fragment_from_index]);
$fragment_index_offset += $fragment_length;
}
if ( $fragment_index_offset > $best_copy_length ) {
$best_copy_length = $fragment_index_offset;
$best_from_start = $from_base_fragment_index;
$best_to_start = $to_base_fragment_index;
}
}
$from_base_fragment_index += mb_strlen($from_base_fragment);
// If match is larger than half segment size, no point trying to find better
// TODO: Really?
if ( $best_copy_length >= $from_segment_length / 2) {
break;
}
// no point to keep looking if what is left is less than
// current best match
if ( $from_base_fragment_index + $best_copy_length >= $from_segment_end ) {
break;
}
}
if ( $best_copy_length ) {
$jobs[] = array($from_segment_start, $best_from_start, $to_segment_start, $best_to_start);
$result[$best_from_start * 4 + 2] = new FineDiffCopyOp($best_copy_length);
$jobs[] = array($best_from_start + $best_copy_length, $from_segment_end, $best_to_start + $best_copy_length, $to_segment_end);
}
else {
$result[$from_segment_start * 4 ] = new FineDiffReplaceOp($from_segment_length, mb_substr($to_text, $to_segment_start, $to_segment_length));
}
}
ksort($result, SORT_NUMERIC);
return array_values($result);
}
/**
* Perform a character-level diff.
*
* The algorithm is quite similar to doFragmentDiff(), except that
* the code path is optimized for character-level diff -- strpos() is
* used to find out the longest common subequence of characters.
*
* We try to find a match using the longest possible subsequence, which
* is at most the length of the shortest of the two strings, then incrementally
* reduce the size until a match is found.
*
* I still need to study more the performance of this function. It
* appears that for long strings, the generic doFragmentDiff() is more
* performant. For word-sized strings, doCharDiff() is somewhat more
* performant.
*/
private static function doCharDiff($from_text, $to_text) {
$result = array();
$jobs = array(array(0, mb_strlen($from_text), 0, mb_strlen($to_text)));
while ( $job = array_pop($jobs) ) {
// get the segments which must be diff'ed
list($from_segment_start, $from_segment_end, $to_segment_start, $to_segment_end) = $job;
$from_segment_len = $from_segment_end - $from_segment_start;
$to_segment_len = $to_segment_end - $to_segment_start;
// catch easy cases first
if ( !$from_segment_len || !$to_segment_len ) {
if ( $from_segment_len ) {
$result[$from_segment_start * 4 + 0] = new FineDiffDeleteOp($from_segment_len);
}
else if ( $to_segment_len ) {
$result[$from_segment_start * 4 + 1] = new FineDiffInsertOp(mb_substr($to_text, $to_segment_start, $to_segment_len));
}
continue;
}
if ( $from_segment_len >= $to_segment_len ) {
$copy_len = $to_segment_len;
while ( $copy_len ) {
$to_copy_start = $to_segment_start;
$to_copy_start_max = $to_segment_end - $copy_len;
while ( $to_copy_start <= $to_copy_start_max ) {
$from_copy_start = mb_strpos(mb_substr($from_text, $from_segment_start, $from_segment_len), mb_substr($to_text, $to_copy_start, $copy_len));
if ( $from_copy_start !== false ) {
$from_copy_start += $from_segment_start;
break 2;
}
$to_copy_start++;
}
$copy_len--;
}
}
else {
$copy_len = $from_segment_len;
while ( $copy_len ) {
$from_copy_start = $from_segment_start;
$from_copy_start_max = $from_segment_end - $copy_len;
while ( $from_copy_start <= $from_copy_start_max ) {
$to_copy_start = mb_strpos(mb_substr($to_text, $to_segment_start, $to_segment_len), mb_substr($from_text, $from_copy_start, $copy_len));
if ( $to_copy_start !== false ) {
$to_copy_start += $to_segment_start;
break 2;
}
$from_copy_start++;
}
$copy_len--;
}
}
// match found
if ( $copy_len ) {
$jobs[] = array($from_segment_start, $from_copy_start, $to_segment_start, $to_copy_start);
$result[$from_copy_start * 4 + 2] = new FineDiffCopyOp($copy_len);
$jobs[] = array($from_copy_start + $copy_len, $from_segment_end, $to_copy_start + $copy_len, $to_segment_end);
}
// no match, so delete all, insert all
else {
$result[$from_segment_start * 4] = new FineDiffReplaceOp($from_segment_len, mb_substr($to_text, $to_segment_start, $to_segment_len));
}
}
ksort($result, SORT_NUMERIC);
return array_values($result);
}
/**
* Efficiently fragment the text into an array according to
* specified delimiters.
* No delimiters means fragment into single character.
* The array indices are the offset of the fragments into
* the input string.
* A sentinel empty fragment is always added at the end.
* Careful: No check is performed as to the validity of the
* delimiters.
*/
private static function extractFragments($text, $delimiters) {
// special case: split into characters
if ( empty($delimiters) ) {
$chars = self::splitToChars($text);
$chars[] = '';
return $chars;
}
$fragments = array();
$start = $end = 0;
for (;;) {
$end += self::mb_strcspn($text, $delimiters, $end);
$end += self::mb_strspn($text, $delimiters, $end);
if ( $end === $start ) {
break;
}
$fragments[$start] = mb_substr($text, $start, $end - $start);
$start = $end;
}
$fragments[$start] = '';
return $fragments;
}
/**
* Stock opcode renderers
*/
private static function renderToTextFromOpcode($opcode, $from, $from_offset, $from_len) {
if ( $opcode === 'c' || $opcode === 'i' ) {
echo mb_substr($from, $from_offset, $from_len);
}
}
private static function countEOL($string) {
$count = 0;
while (mb_strpos($string, "\n") !== FALSE) {
$count++;
$string = mb_substr($string, mb_strpos($string, "\n") + 1);
}
return $count;
}
private static function renderDiffToHTMLFromOpcode($opcode, $from, $from_offset, $from_len) {
if ( $opcode === 'c' ) {
echo htmlspecialchars(mb_substr($from, $from_offset, $from_len));
}
else if ( $opcode === 'd' ) {
$deletion = mb_substr($from, $from_offset, $from_len);
/**
* If $deletion contain just one "\n" on the end of line, remove this "\n"
* Now deleted and inserted text are in one row.
* IMHO this is better readable for human beings.
*/
if (self::countEOL($deletion) === 1 && mb_substr($deletion, -1)) {
$deletion = str_replace("\n", '', $deletion);
}
if ( strcspn($deletion, " \n\r") === 0 ) { // no mb_ here is okay
$deletion = str_replace(array("\n","\r"), array('\n','\r'), $deletion);
}
echo '<del>', htmlspecialchars($deletion), '</del>';
}
else /* if ( $opcode === 'i' ) */ {
echo '<ins>', htmlspecialchars(mb_substr($from, $from_offset, $from_len), ENT_QUOTES), '</ins>';
}
}
private static function splitToChars($str) {
preg_match_all('/./us', $str, $matches);
$matches = $matches[0];
if (count($matches) === 0) return array('');
return $matches;
}
private static function mb_strcspn($str, $delimiters, $start) {
$dels = self::splitToChars($delimiters);
$min = mb_strlen($str);
foreach ($dels as $del) {
$pos = mb_strpos($str, $del, $start);
if ($pos !== false && $pos < $min) $min = $pos;
}
return $min - $start;
}
private static function mb_strspn($str, $delimiters, $start) {
$str = mb_substr($str, $start);
$dels = self::splitToChars($delimiters);
foreach ($dels as $idx => $del) {
$dels[$idx] = preg_quote($del, '/');
}
$dels = implode('|', $dels);
preg_match("/^($dels)+/us", $str, $match);
return $match ? mb_strlen($match[0]) : 0;
}
}

8
include/footer.php Normal file
View File

@ -0,0 +1,8 @@
<?php
echo <<<FOOTER
</div>
</body>
</html>
FOOTER;
?>

138
include/header.php Normal file
View File

@ -0,0 +1,138 @@
<?php
function format_incipit($incipit) {
return $incipit = strtr($incipit, array(' Ps.' => ' <i>Ps.</i>',' cum Alleluia' => ' <i>cum</i> Alleluia',' sine Alleluia' => ' <i>sine</i> Alleluia','('=>'<i>(',')'=>')</i>'));
}
class RomanNumber {
//array of roman values
public static $roman_values=array(
'I' => 1, 'V' => 5,
'X' => 10, 'L' => 50,
'C' => 100, 'D' => 500,
'M' => 1000,
);
//values that should evaluate as 0
public static $roman_zero=array('N', 'nulla');
//Regex - checking for valid Roman numerals
public static $roman_regex='/^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/';
//Roman numeral validation function - is the string a valid Roman Number?
static function IsRomanNumber($roman) {
return preg_match(self::$roman_regex, $roman) > 0;
}
//Conversion: Roman Numeral to Integer
static function Roman2Int ($roman) {
//checking for zero values
if (in_array($roman, self::$roman_zero)) {
return 0;
}
//validating string
if (!self::IsRomanNumber($roman)) {
return false;
}
$values=self::$roman_values;
$result = 0;
//iterating through characters LTR
for ($i = 0, $length = strlen($roman); $i < $length; $i++) {
//getting value of current char
$value = $values[$roman[$i]];
//getting value of next char - null if there is no next char
$nextvalue = !isset($roman[$i + 1]) ? null : $values[$roman[$i + 1]];
//adding/subtracting value from result based on $nextvalue
$result += (!is_null($nextvalue) && $nextvalue > $value) ? -$value : $value;
}
return $result;
}
}
$days = array('sund','sunday','sundays','monday','tuesday','wednesday','thursday','friday','saturday');
$hours = array('matins','lauds','prime','terce','sext','none','vespers','compline');
function custom_split($str) {
global $days, $hours;
$test = preg_split('/(?=[a-z]+[^A-Z]?)|(?<=\D)\d|(?<=\d)\D|[ \.,\(\)]/', $str,0,PREG_SPLIT_NO_EMPTY);
$i = 1;
while(count($test) > $i) {
if(ctype_alpha($test[$i]) && ctype_alpha($test[$i-1]) &&
!RomanNumber::IsRomanNumber($test[$i]) && !RomanNumber::IsRomanNumber($test[$i-1]) &&
!in_array(strtolower($test[$i]),$days) && !in_array(strtolower($test[$i-1]),$days) &&
!in_array(strtolower($test[$i]),$hours) && !in_array(strtolower($test[$i-1]),$hours)) {
$test[$i-1] = $test[$i-1].$test[$i];
unset($test[$i]);
$test = array_values($test);
} else {
$i++;
}
}
return $test;
}
function custom_cmp($a,$b) {
global $days, $hours;
$u = array($a['office-part'],$b['office-part']);
$v = array($a['version'],$b['version']);
$a = custom_split($a['incipit']);
$b = custom_split($b['incipit']);
for($i = 0; $i < min(count($a),count($b)); $i++) {
if(RomanNumber::IsRomanNumber($a[$i]) && RomanNumber::IsRomanNumber($b[$i])) {
$a[$i] = RomanNumber::Roman2Int($a[$i]);
$b[$i] = RomanNumber::Roman2Int($b[$i]);
} elseif(in_array(strtolower($a[$i]), $days) && in_array(strtolower($b[$i]), $days)) {
$a[$i] = array_search(strtolower($a[$i]), $days);
$b[$i] = array_search(strtolower($b[$i]), $days);
} elseif(in_array(strtolower($a[$i]), $hours) && in_array(strtolower($b[$i]), $hours)) {
$a[$i] = array_search(strtolower($a[$i]), $hours);
$b[$i] = array_search(strtolower($b[$i]), $hours);
}
if(strtolower($a[$i]) != strtolower($b[$i])) {
return (strtolower($a[$i]) < strtolower($b[$i])) ? -1 : 1;
}
}
if($a < $b) {
return -1;
} else {
return 1;
}
if($u[0] != $u[1]) {
return ($u[0] < $u[1]) ? -1 : 1;
}
return ($v[0] < $v[1]) ? -1 : 1;
}
echo <<<HEADER1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title>GregoBase - $title</title>
<link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Libre+Baskerville:400,700,400italic' />
<link rel="stylesheet" type="text/css" href="style.css" />
HEADER1;
if(!$logged_in) {
echo '<script type="text/javascript" src="sha512.js"></script>
<script type="text/javascript" src="forms.js"></script>
';
}
echo <<<HEADER2
</head>
<body>
<div id="header">
<div id="title"><h1><a href="./">GregoBase</a></h1></div>
<div id="description">A database of gregorian scores</div>
<div id="access">
<div class="menu"><ul class="sf-menu"><li class="page_item current_page_item"><a href="scores.php">Scores</a></li><li class="page_item"><a href="./?page_id=5">Todo</a></li><li class="page_item"><a href="./?page_id=2">About</a></li></ul></div>
</div><!-- #access -->
</div>
<div id="header_overlay"></div>
<div id="content">
HEADER2;
?>

10
include/sources.php Normal file
View File

@ -0,0 +1,10 @@
<?php
$sources = array();
$sql1 = 'SELECT * FROM '.$db['sources'].' ORDER BY year,editor,title';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error());
while ($s = $req1->fetch_assoc()) {
$sources[$s['id']] = array('year' => $s['year'], 'editor' => $s['editor'], 'title' => $s['title'], 'description' => $s['description'], 'caption' => $s['caption'], 'pages' => json_decode($s['pages']));
}
?>

37
include/txt.php Normal file
View File

@ -0,0 +1,37 @@
<?php
$txt = array();
$txt['usage'] = array();
$txt['usage']['al'] = 'Alleluia';
$txt['usage']['an'] = 'Antiphona';
$txt['usage']['ca'] = 'Canticum';
$txt['usage']['co'] = 'Communio';
$txt['usage']['gr'] = 'Graduale';
$txt['usage']['hy'] = 'Hymnus';
$txt['usage']['in'] = 'Introitus';
$txt['usage']['im'] = 'Improperia';
$txt['usage']['ky'] = 'Kyriale';
$txt['usage']['of'] = 'Offertorium';
$txt['usage']['ps'] = 'Psalmus';
$txt['usage']['re'] = 'Responsorium';
$txt['usage']['se'] = 'Sequentia';
$txt['usage']['tr'] = 'Tractus';
$txt['usage']['va'] = 'Varia';
$txt['usage_s'] = array();
$txt['usage_s']['al'] = '';
$txt['usage_s']['an'] = 'Ant';
$txt['usage_s']['ca'] = 'Cant';
$txt['usage_s']['co'] = 'Comm';
$txt['usage_s']['gr'] = 'Grad';
$txt['usage_s']['hy'] = 'Hymn';
$txt['usage_s']['in'] = 'Intr';
$txt['usage_s']['im'] = '';
$txt['usage_s']['ky'] = '';
$txt['usage_s']['of'] = 'Offert';
$txt['usage_s']['ps'] = '';
$txt['usage_s']['re'] = 'Resp';
$txt['usage_s']['se'] = 'Seq';
$txt['usage_s']['tr'] = 'Tract';
$txt['usage_s']['va'] = '';
?>

17
index.php Normal file
View File

@ -0,0 +1,17 @@
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');

24
mgabc.php Normal file
View File

@ -0,0 +1,24 @@
<?php
include('include/db.php');
$title = 'MGABC';
include('include/header.php');
echo "<h2>$title</h2>\n";
$sql1 = 'SELECT * FROM '.db('chants').' WHERE `gabc` LIKE "[%" ORDER BY incipit ASC';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
echo "<ul class=\"incipit\">\n";
while($c = $req1->fetch_assoc()) {
$incipit = $c['incipit']?format_incipit($c['incipit']):"===";
echo '<li class="usage-marker '.$c['office-part'].'">';
if($c['gabc'] > '') {
echo '<a href="chant.php?id='.$c['id'].'">'.$incipit."</a>";
} else {
echo '<span class="todo">'.$incipit.'</span>';
}
echo ' <span class="version">('.$c['version'].")</span></li>\n";
}
echo "</ul>\n";
include('include/footer.php');
?>

46
scores.php Normal file
View File

@ -0,0 +1,46 @@
<?php
include('include/db.php');
include('include/txt.php');
include('include/sources.php');
$title = 'Home';
include('include/header.php');
echo "<h3>Chants</h3>\n";
echo "<h4>by source</h4>\n";
$sql1 = 'SELECT * FROM '.$db['chant_sources'].' GROUP BY source';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
echo "<div><ul>\n";
$used_sources = array();
while($s = $req1->fetch_assoc()) {
$used_sources[] = $s['source'];
}
foreach($sources as $id => $s) {
if(in_array($id, $used_sources)) {
echo "<li><a href=\"source.php?id=".$id."\">".$s['year']." - ".$s['editor']." - ".$s['title']."</a></li>\n";
}
}
$sql1 = 'SELECT * FROM '.$db['chants'].' c WHERE NOT EXISTS (SELECT * FROM '.$db['chant_sources'].' cs WHERE c.id = cs.chant_id)';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error());
if($req1->num_rows > 0) {
echo "<li><a href=\"source.php?id=none\">No source</a></li>\n";
}
echo "</ul></div>\n";
echo "<h4>by usage</h4>\n";
$sql1 = 'SELECT * FROM '.$db['chants'].' WHERE `office-part` != "" GROUP BY `office-part` ORDER BY `office-part`';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error());
echo "<div><ul>\n";
while($s = $req1->fetch_assoc()) {
echo '<li class="usage '.$s['office-part'].'"><a href="usage.php?id='.$s['office-part'].'">'.$txt['usage'][$s['office-part']]."</a></li>\n";
}
echo "</ul></div>\n";
echo "<h4>by incipit</h4>\n";
$sql1 = 'SELECT DISTINCT UPPER(SUBSTRING(incipit,1,1)) AS letters FROM '.$db['chants'].' ORDER BY letters ASC';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error());
echo "<div><ul>\n";
while($s = $req1->fetch_assoc()) {
echo "<li><a href=\"incipit.php?letter=".$s['letters']."\">".($s['letters']?$s['letters']:"no incipit")."</a></li>\n";
}
echo "</ul></div>\n";
include('include/footer.php');
?>

69
source.php Normal file
View File

@ -0,0 +1,69 @@
<?php
include('include/db.php');
include('include/sources.php');
if(array_key_exists("id", $_GET)) {
$s = intval($_GET['id']);
} else {
die('No id');
}
$chants = array();
if($s == "none") {
$sql1 = 'SELECT * FROM '.$db['chants'].' c WHERE NOT EXISTS (SELECT * FROM '.$db['chant_sources'].' cs WHERE c.id = cs.chant_id)';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
while($c = $req1->fetch_assoc()) {
$chants[''][] = array($c['id'],1,1);
}
} else {
$sql1 = 'SELECT * FROM '.$db['chant_sources'].' WHERE `source` = "'.$s.'" ORDER BY sequence ASC';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
while($c = $req1->fetch_assoc()) {
$chants[$c['page']][] = array($c['chant_id'],$c['sequence'],$c['extent']);
}
}
$title = 'Sources - '.$sources[$s]['title'];
include('include/header.php');
echo "<h2>$title</h2>\n";
echo "<table>\n<tr><th>Page</th><th>Incipit</th></tr>";
if(is_array($sources[$s]['pages'])) {
foreach($sources[$s]['pages'] as $p) {
if(array_key_exists($p,$chants)) {
echo "<tr><td>$p</td><td>";
echo "<ul class=\"incipit\">\n";
$ch = $chants[$p];
unset($chants[$p]);
foreach($ch as $c) {
$t = chant_from_id($c[0]);
echo '<li class="usage-marker '.$t[0].'">';
if($t[2]) {
echo '<a href="chant.php?id='.$c[0].'">'.format_incipit($t[1])."</a>";
} else {
echo '<span class="todo">'.format_incipit($t[1]).'</span>';
}
echo "</li>\n";
}
echo "</ul>\n";
echo "</td></tr>\n";
}
}
}
uksort($chants, 'strnatcmp');
foreach($chants as $p => $ch) {
echo "<tr><td>$p</td><td><ul class=\"incipit\">";
$l = array();
foreach($ch as $c) {
$t = chant_from_id($c[0]);
$l[] = $t[1]."=-=".$t[0]."=-=".$c[0]."=-=".$c[1]."=-=".$c[2];
}
natcasesort($l);
foreach($l as $ll) {
$ll = explode('=-=',$ll);
echo '<li class="usage-marker '.$ll[1].'"><a href="chant.php?id='.$ll[2].'">'.$ll[0]."</a></li>\n";
}
echo "</ul></td></tr>\n";
}
echo "</table>\n";
include('include/footer.php');
?>

371
style.css Normal file
View File

@ -0,0 +1,371 @@
html, body {
margin: 0px;
background: #fff;
background-image: url("wp-content/themes/gregobase/bg.png");
background-repeat: repeat-x;
background-position: top;
color: #000;
font-family: 'Libre Baskerville', Georgia, serif;
height:100%;
max-height:100%;
font-size: 10pt;
}
h1 {
font-size:18pt;
font-weight:bold;
padding: 0px;
}
h1 a {
color: #222;
text-decoration:none;
}
a:link
{
color: #004b91;
}
a:active, a:hover
{
color: #ff4b33;
}
table {
border-collapse: collapse;
}
td {
vertical-align: top;
border-top: solid lightgray 1px;
}
table.registration {
margin-left:auto;
margin-right:auto;
}
table.registration th {
text-align: right;
}
table.registration td {
text-align: left;
border: none;
}
td ul {
margin-top: 0px;
margin-bottom: 0px;
}
h4 + ul {
margin-top: 0px;
margin-bottom: 0px;
}
h4 {
padding-bottom: 0px;
margin-bottom: 0px;
}
#header {
position: absolute;
top: 0px;
width: 1024px;
height: 150px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
}
#title {
padding: 0.2em 12px;
}
#description {
padding: 0em 15px;
color:#222;
font-size:12pt;
font-style:italic;
}
#header_overlay {
position: absolute;
top: 0px;
width: 190px;
height: 150px;
background-image: url("wp-content/themes/gregobase/monks.png");
background-repeat: no-repeat;
background-position: right;
left: 50%;
margin-left: 322px;
}
#content {
box-sizing:border-box;
-moz-box-sizing:border-box; /* Firefox */
-webkit-box-sizing:border-box; /* Safari */
position: absolute;
top: 150px;
bottom: 0px;
width: 1024px;
overflow: auto;
padding-left: 20px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
border-left: solid 1px #e6e6e6;
}
#score {
position: absolute;
width:475px;
top: 0px;
left: 15px;
bottom: 0px;
overflow: auto;
}
#info {
position: absolute;
top: 0px;
left: 490px;
right:0px;
bottom: 0px;
overflow: auto;
padding-left: 20px;
}
.version {
color: #999;
font-size: 8pt;
}
ul.incipit {
list-style: none;
padding:0;
margin:0;
}
ul.incipit li {
padding-left: 2em;
}
.usage-marker:before {
content: "■";
padding-right:7px;
}
.usage:after {
content: "■";
padding-left:4px;
}
.ky:before, .ky:after {
color: #085abd;
}
.al:before, .al:after {
color: #84c6ff;
}
.an:before, .an:after {
color: #efce31;
}
.ca:before, .ca:after {
color: #67674c;
}
.co:before, .co:after {
color: #94944a;
}
.gr:before, .gr:after {
color: #a6ff4b;
}
.hy:before, .hy:after {
color: #c68c63;
}
.im:before, .im:after {
color: #845239;
}
.in:before, .in:after {
color: #c52d31;
}
.of:before, .of:after {
color: #7b7b52;
}
.ps:before, .ps:after {
color: #567d8e;
}
.re:before, .re:after {
color: #736342;
}
.se:before, .se:after {
color: #8c7b5a;
}
.tr:before, .tr:after {
color: #d68c10;
}
.va:before, .va:after {
color: #cccccc;
}
.todo {
color: #999;
}
ins {
color: white;
background: green;
text-decoration: none;
}
del {
color: white;
background: red;
text-decoration: none;
}
textarea#gabc {
width: 440px;
height: 200px;
}
/* =Menu
-------------------------------------------------------------- */
.skip-link {
display:none;
}
#access {
position: absolute;
top: 121px;
height:28px;
font-size:13px;
overflow:visible;
z-index:100;
}
/*** ESSENTIAL STYLES ***/
.sf-menu, .sf-menu * {
margin:0;
padding:0;
list-style:none;
}
.sf-menu {
line-height:1.0;
}
.sf-menu ul {
position:absolute;
top:-999em;
width:10em; /* left offset of submenus need to match (see below) */
}
.sf-menu ul li {
width:100%;
}
.sf-menu li:hover {
visibility:inherit; /* fixes IE7 'sticky bug' */
}
.sf-menu li {
float:left;
position:relative;
}
.sf-menu a {
display:block;
position:relative;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
left:0;
top:2.5em; /* match top ul list item height */
z-index:99;
}
ul.sf-menu li:hover li ul,
ul.sf-menu li.sfHover li ul {
top:-999em;
}
ul.sf-menu li li:hover ul,
ul.sf-menu li li.sfHover ul {
left:10em; /* match ul width */
top:0;
}
ul.sf-menu li li:hover li ul,
ul.sf-menu li li.sfHover li ul {
top:-999em;
}
ul.sf-menu li li li:hover ul,
ul.sf-menu li li li.sfHover ul {
left:10em; /* match ul width */
top:0;
}
/*** THEMATIC SKIN ***/
.sf-menu {
float:left;
margin-left:1px;
}
.sf-menu a {
border-color:#e6e6e6;
border-style:solid;
border-width:1px;
padding:7px 13px;
text-decoration:none;
margin-left:-1px;
}
.ie7 .sf-menu a {
width:100%;
}
.sf-menu .current-menu-item a,
.sf-menu .current-menu-parent a,
.sf-menu .current-menu-ancestor a,
.sf-menu .current-post-ancestor a,
.sf-menu .current_page_item a,
.sf-menu .current_page_ancestor a,
.sf-menu .current_page_parent a {
border-bottom-color:#fff;
}
.sf-menu a, .sf-menu a:visited { /* visited pseudo selector so IE6 applies text colour*/
color:#666;
}
.sf-menu li {
background:#fff;
}
.sf-menu li li {
background:#fff;
}
.sf-menu li li li {
background:#9AAEDB;
}
.sf-menu li:hover, .sf-menu li.sfHover,
.sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {
background:#fafafa;
outline: 0;
border-bottom-color:#e6e6e6;
}
.sf-menu ul {
border-bottom:1px solid #e6e6e6;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
top:127px; /* overriding essential styles */
}
.sf-menu ul ul {
margin-top:0;
}
.sf-menu ul a {
background:#fafafa;
border-bottom:none;
}
.sf-menu ul a:hover {
color: #FF4B33;
}

38
usage.php Normal file
View File

@ -0,0 +1,38 @@
<?php
include('include/db.php');
include('include/txt.php');
if(array_key_exists("id", $_GET)) {
$id = $_GET['id'];
} else {
die('No id');
}
if(!array_key_exists($id,$txt['usage'])) {
die('Wrong id');
}
$title = 'Usage - '.$txt['usage'][$id];
include('include/header.php');
echo "<h2>$title</h2>\n";
$sql1 = 'SELECT * FROM '.$db['chants'].' WHERE `office-part` = "'.$id.'" ORDER BY incipit ASC';
$req1 = $mysqli->query($sql1) or die('Erreur SQL !<br />'.$sql1.'<br />'.$mysqli->error);
$chants = array();
while($c = $req1->fetch_assoc()) {
$chants[] = $c;
}
if(count($chants)) {
usort($chants, "custom_cmp");
}
echo "<ul>\n";
foreach($chants as $c) {
$incipit = $c['incipit']?format_incipit($c['incipit']):"===";
echo '<li>';
if($c['gabc'] > '') {
echo '<a href="chant.php?id='.$c['id'].'">'.$incipit."</a>";
} else {
echo '<span class="todo">'.$incipit.'</span>';
}
echo " <span class=\"version\">(".$c['version'].")</span></li>\n";
}
echo "</ul>\n";
include('include/footer.php');
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -0,0 +1,820 @@
/* =Global Elements
-------------------------------------------------------------- */
body, input, textarea {
font:11pt 'Libre Baskerville',Georgia,serif;
}
p, ul, ol, dd, pre {
margin-bottom:22px;
}
pre, code {
font:11pt Monaco, monospace;
}
blockquote {
color:#666;
font-style:italic;
}
table {
border:1px solid #e6e6e6;
border-width:1px 1px 0 1px;
font-size:13px;
line-height:18px;
margin:0 0 22px 0;
text-align:left;
}
caption {
text-align:left;
}
tr {
border-bottom:1px solid #e6e6e6;
}
th, td {
padding: .7em 1.25em;
}
hr {
background-color:#e6e6e6;
border:0;
height:1px;
margin-bottom:22px;
}
.ie7 hr {
background-color:transparent;
color:#ccc;
}
a:link {
color:#004B91;
}
a:visited {
color:#743399;
}
a:active,
a:hover {
color: #FF4B33;
}
/* =Header
-------------------------------------------------------------- */
#header {
z-index:2;
}
#branding {
padding:88px 0 44px 0;
}
#blog-title {
font-size:18pt;
font-weight:bold;
padding: 0.8em 12px;
}
#blog-title a {
color:#222;
text-decoration:none;
}
#blog-title a:active,
#blog-title a:hover {
color: #FF4B33;
}
#blog-description {
color:#222;
font-size:12pt;
font-style:italic;
padding: 0px 15px;
}
/* =Menu
-------------------------------------------------------------- */
.skip-link {
display:none;
}
#access {
position: absolute;
top: 121px;
height:28px;
font-size:13px;
overflow:visible;
z-index:100;
}
/*** ESSENTIAL STYLES ***/
.sf-menu, .sf-menu * {
margin:0;
padding:0;
list-style:none;
}
.sf-menu {
line-height:1.0;
}
.sf-menu ul {
position:absolute;
top:-999em;
width:10em; /* left offset of submenus need to match (see below) */
}
.sf-menu ul li {
width:100%;
}
.sf-menu li:hover {
visibility:inherit; /* fixes IE7 'sticky bug' */
}
.sf-menu li {
float:left;
position:relative;
}
.sf-menu a {
display:block;
position:relative;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
left:0;
top:2.5em; /* match top ul list item height */
z-index:99;
}
ul.sf-menu li:hover li ul,
ul.sf-menu li.sfHover li ul {
top:-999em;
}
ul.sf-menu li li:hover ul,
ul.sf-menu li li.sfHover ul {
left:10em; /* match ul width */
top:0;
}
ul.sf-menu li li:hover li ul,
ul.sf-menu li li.sfHover li ul {
top:-999em;
}
ul.sf-menu li li li:hover ul,
ul.sf-menu li li li.sfHover ul {
left:10em; /* match ul width */
top:0;
}
/*** THEMATIC SKIN ***/
.sf-menu {
float:left;
margin-left:1px;
}
.sf-menu a {
border-color:#e6e6e6;
border-style:solid;
border-width:1px;
padding:7px 13px;
text-decoration:none;
margin-left:-1px;
}
.ie7 .sf-menu a {
width:100%;
}
.sf-menu .current-menu-item a,
.sf-menu .current-menu-parent a,
.sf-menu .current-menu-ancestor a,
.sf-menu .current-post-ancestor a,
.sf-menu .current_page_item a,
.sf-menu .current_page_ancestor a,
.sf-menu .current_page_parent a {
border-bottom-color:#fff;
}
.sf-menu a, .sf-menu a:visited { /* visited pseudo selector so IE6 applies text colour*/
color:#666;
}
.sf-menu li {
background:#fff;
}
.sf-menu li li {
background:#fff;
}
.sf-menu li li li {
background:#9AAEDB;
}
.sf-menu li:hover, .sf-menu li.sfHover,
.sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {
background:#fafafa;
outline: 0;
border-bottom-color:#e6e6e6;
}
.sf-menu ul {
border-bottom:1px solid #e6e6e6;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
top:127px; /* overriding essential styles */
}
.sf-menu ul ul {
margin-top:0;
}
.sf-menu ul a {
background:#fafafa;
border-bottom:none;
}
.sf-menu ul a:hover {
color: #FF4B33;
}
/* =Content
-------------------------------------------------------------- */
#main {
clear:both;
padding:66px 0 22px 0;
}
.page-title {
font-size:13px;
line-height:18px;
padding:0 0 44px 0;
}
.attachment .page-title {
font-style:italic;
}
.page-title a {
color:#666;
text-decoration:none;
}
.page-title a:active,
.page-title a:hover {
color: #FF4B33;
}
.page-title span {
font-style:italic;
}
.page-title .meta-nav {
font-style:normal;
}
.hentry {
padding:0 0 22px 0;
}
.single .hentry {
padding:0;
}
.home #content .sticky {
border:1px solid #e6e6e6;
margin:0 0 66px 0;
padding:22px 20px 0 20px;
}
.entry-title {
font-size:16pt;
font-weight:bold;
padding:0 0 7px 0;
}
.entry-title a {
color:#000;
text-decoration:none;
}
.entry-title a:active,
.entry-title a:hover {
color: #FF4B33;
}
.entry-meta {
color:#666;
font-size:13px;
font-style:italic;
line-height:18px;
}
.entry-meta .author {
}
.entry-meta .n, .entry-meta .nickname {
font-size:11px;
font-style:normal;
letter-spacing:0.05em;
text-transform:uppercase;
}
.entry-meta a {
color:#666;
text-decoration:none;
}
.entry-meta a:active,
.entry-meta a:hover {
color: #FF4B33;
}
.entry-meta abbr {
border:none;
cursor:text;
font-size:11px;
font-style:normal;
letter-spacing:0.05em;
text-transform:uppercase;
}
.entry-content {
padding:22px 0 0 0;
}
.entry-content h1,
.entry-content h2 {
font-family:Arial,sans-serif;
font-size:19px;
font-weight:bold;
padding:28px 0 14px 0;
}
.entry-content h3 {
font-size:17px;
font-style:italic;
padding:28px 0 14px 0;
}
.entry-content h4 {
font-size:11px;
font-family:Arial,sans-serif;
font-weight:bold;
text-transform:uppercase;
letter-spacing:0.05em;
}
.entry-content table {
margin-left:1px;
}
.entry-content embed {
margin:0 0 22px 0;
}
.entry-utility {
clear:both;
color:#666;
font-size:13px;
line-height:18px;
margin:0 0 44px 0;
}
.entry-utility a {
color:#666;
font-style:italic;
text-decoration:none;
}
.entry-utility a:active,
.entry-utility a:hover {
color: #FF4B33;
}
.page .edit-link {
clear:both;
display:block;
}
.page-link {
clear:both;
font-size:13px;
font-weight:bold;
line-height:18px;
margin:0 0 22px 0;
padding:22px 0 0 0;
word-spacing:0.5em;
}
.page-link a {
border:1px solid #e6e6e6;
color:#666;
font-weight:normal;
padding:0.5em 0.75em;
text-decoration:none;
}
.page-link a:active,
.page-link a:hover {
color: #FF4B33;
}
ul#links-page,
ul#archives-page {
list-style:none;
margin-left:0;
overflow:hidden;
}
li.content-column {
float:left;
margin-right:20px;
width:45%;
}
#author-info {
margin:0 0 44px 0;
overflow:hidden;
}
#author-info .avatar {
float:left;
margin:.3em 1em 0 0;
}
/* =Attachments
-------------------------------------------------------------- */
.attachment-jpeg #container,
.attachment-png #container {
width:100%;
}
.attachment-jpeg #content,
.attachment-png #content {
width:930px;
}
.attachment-jpeg #comments,
.attachment-png #comments {
width:540px;
overflow:hidden;
}
.attachment-jpeg .main-aside,
.attachment-png .main-aside {
display:none;
}
/* =Navigation
-------------------------------------------------------------- */
.navigation {
color:#666;
font-size:13px;
line-height:18px;
margin:0px 0 22px 0;
overflow:hidden;
}
.navigation a {
color:#666;
font-style:italic;
text-decoration:none;
}
.navigation a:active,
.navigation a:hover {
color: #FF4B33;
}
.navigation .meta-nav {
font-style:normal;
}
.nav-previous {
float: left;
width:50%;
}
.nav-next {
float: right;
width:50%;
text-align:right;
}
#nav-above,#nav-below {
width: 100%;
}
#nav-above {
display:none;
}
.paged #nav-above {
display:block;
padding:0 0 44px 0;
}
/* =Comments
-------------------------------------------------------------- */
#comments {
clear:both;
padding:22px 0 0 0;
}
#comments,
#comments input,
#comments textarea {
font-size:13px;
line-height:18px;
}
#comments code {
font-size:12px;
line-height:18px;
}
#comments h3 {
font-family:Arial,sans-serif;
font-size:15px;
font-weight:bold;
line-height:22px;
padding:0 0 18px 0;
}
#comments-list {
border:1px solid #e6e6e6;
border-bottom:none;
margin:0 0 18px;
}
#comments-list h3 {
padding-bottom: 0;
}
#comments-list,
#comments-list ul {
list-style:none;
}
#comments-list ul,
#comments-list ol {
padding-bottom: 18px;
}
#comments-list ul ul,
#comments-list ol ol,
#comments-list ul ul ul,
#comments-list ol ol ol {
padding-bottom:0;
}
#comments-list .comment {
background:#fafafa;
border-bottom:1px solid #e6e6e6;
padding:18px 1.5em 0 1.5em;
position:relative;
}
#comments-list li.alt {
background:#fff;
}
#comments-list li.bypostauthor {
background:#FFFFCC;
}
#comments-list ul .comment {
border:1px solid #e6e6e6;
margin:0 0 18px 0;
}
#comments-list li .avatar {
position:absolute;
top:22px;
left:1.5em;
width:36px;
height:36px;
}
#comments-list .comment-author {
font-weight:bold;
padding:9px 0 0 46px;
}
#comments-list .comment-meta {
color:#666;
font-size:11px;
padding:0 0 9px 46px;
}
#comments-list .comment-meta a {
color:#666;
font-style:italic;
text-decoration:none;
}
#comments-list .comment-meta a:active,
#comments-list .comment-meta a:hover {
color: #FF4B33;
}
.comment-reply-link {
font-size:11px;
padding:0 0 18px 0;
text-align:right;
}
.comment-reply-link a {
color:#666;
font-style:italic;
text-decoration:none;
}
.comment-reply-link a:active,
.comment-reply-link a:hover {
color: #FF4B33;
}
.comment-navigation {
font-weight:bold;
padding: 18px 0 24px;
margin-right:0.5em;
}
.comment-navigation a {
border:1px solid #e6e6e6;
color:#666;
font-weight:normal;
padding:0.5em 0.75em;
text-decoration:none;
}
.comment-navigation a:active,
.comment-navigation a:hover {
color: #FF4B33;
}
.comment-navigation a,
.comment-navigation span {
margin-right:0.5em;
}
#trackbacks-list .comment-content {
position:absolute;
left:-10000px;
}
#respond {
background:#fff;
margin-bottom:22px;
overflow:hidden;
padding:18px 0 0 0;
position:relative;
}
#comments-list #respond {
border-bottom:1px solid #e6e6e6;
margin:0 0 18px 0;
padding:18px 1.5em;
}
#comments-list ul #respond {
border:1px solid #e6e6e6;
margin:0;
}
#cancel-comment-reply {
font-size:11px;
position:absolute;
top:18px;
right:1.5em;
}
#cancel-comment-reply a {
color:#666;
}
#respond .required {
color:#FF4B33;
font-weight:bold;
}
.form-section label {
font-size:11px;
}
.form-section input {
margin:0 0 18px 0;
width:98%;
}
.form-section textarea {
width:99%;
}
#form-allowed-tags p {
color:#666;
font-size:11px;
margin:0;
}
#form-allowed-tags span {
font-style:italic;
}
#form-allowed-tags code {
font-size:11px;
line-height:normal;
}
.form-submit {
padding:18px 0 0 0;
text-align:right;
}
.subscribe-to-comments {
color:#666;
float:left;
font-size:11px;
margin:0;
padding:18px 0 0 0;
}
.solo-subscribe-to-comments {
color:#666;
font-size:11px;
padding:18px 0 0 0;
}
.comment_license {
color:#666;
clear:both;
font-size:11px;
margin:0;
padding:18px 0 0 0;
}
/* =Asides, Sidebars & Widget-Ready Areas
-------------------------------------------------------------- */
.aside,
.aside input {
font-size:13px;
line-height:18px;
margin-bottom:6px;
}
.aside p,
.aside ul,
.aside ol,
.aside dd,
.aside pre {
margin-bottom:18px;
}
.aside pre,
.aside code {
font-size:12px;
line-height:18px;
}
.aside .current-menu-item a,
.aside .current_page_item a {
color: #FF4B33;
}
.aside .current-menu-item .menu-item a,
.aside .current_page_item .menu-item a {
color:#666;
}
.aside .current-menu-item .menu-item a:hover,
.aside .current-menu-item .menu-item a:active,
.aside .current_page_item .menu-item a:hover,
.aside .current_page_item .menu-item a:active {
color: #FF4B33;
}
.aside {
color:#666;
}
.aside a {
color:#666;
}
.aside a:active,
.aside a:hover {
color: #FF4B33;
}
.aside h3 {
font-size:15px;
font-style:italic;
line-height:22px;
}
.aside h3 a {
text-decoration:none;
}
.aside caption {
font-size:11px;
font-family:Arial,sans-serif;
font-weight:bold;
text-transform:uppercase;
letter-spacing:0.05em;
}
.aside ul {
list-style:none;
margin-left:0;
}
.aside ul ul {
list-style:disc;
margin:0 0 22px 20px;
}
.aside ul ul li {
padding:1px 0;
}
.aside ul ul ul {
margin-bottom:0;
}
.aside form,
.aside table {
margin-bottom:22px;
}
.aside table {
border:none;
}
.aside thead {
border:1px solid #e6e6e6;
}
.aside tbody {
border:1px solid #e6e6e6;
}
.aside th, .aside td {
border-right:1px solid #e6e6e6;
padding:.25em .8em;
}
.aside tfoot tr {
border:none;
}
.aside tfoot td {
border-color:transparent;
}
.widget_tag_cloud {
margin:0 0 22px 0;
}
.aside #searchsubmit {
display: none;
}
/*
Main Asides
*/
.main-aside ul {
padding:0 20px;
}
.main-aside h3 {
}
.main-aside ul ul {
padding:0;
}
#primary {
border:1px solid #e6e6e6;
padding:18px 0 0 0;
margin-bottom:22px;
}
/*
Content Asides
*/
#content .aside {
border:1px solid #e6e6e6;
margin:0 0 22px 0;
padding:18px 0 0 0;
}
#content .aside ul {
padding:0 20px;
}
#content .aside h3 {
font-family:'Libre Baskerville',Georgia,serif;
font-weight:normal;
font-size:17px;
font-style:italic;
padding:0 0 7px 0;
text-transform:none;
}
#content .aside ul ul {
padding:0;
}
/*
Footer Asides
*/
#subsidiary {
padding:33px 0 0 0;
}
/* =Footer
-------------------------------------------------------------- */
#footer {
border-top:1px solid #e6e6e6;
margin-top:22px;
}
#siteinfo {
color:#666;
font-size:11px;
line-height:18px;
padding:22px 0 44px 0;
}
#siteinfo a {
color:#666;
}
#siteinfo a:active,
#siteinfo a:hover {
color: #FF4B33;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

View File

@ -0,0 +1,90 @@
/*
Theme Name: GregoBase
Theme URI: http://thematictheme.com/
Description: Use this theme to start your Thematic Child Theme development.
Author: Ian Stewart
Author URI: http://themeshaper.com/
Template: thematic
Version: 1.0
Tags: white, three-columns, two-columns, fixed-width, theme-options, left-sidebar, right-sidebar, threaded-comments, sticky-post, microformats
License: GNU General Public License v2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.html
.
The Thematic Theme is copyright Ian Stewart http://themeshaper.com/
This work, like WordPress, is released under GNU General Public License, version 2 (GPL).
.
*/
/* Reset browser defaults */
@import url('../thematic/library/styles/reset.css');
/* Apply basic typography styles */
@import url('../thematic/library/styles/typography.css');
/* Apply a basic layout */
@import url('../thematic/library/layouts/2c-r-fixed.css');
/* Apply basic image styles */
@import url('../thematic/library/styles/images.css');
/* Apply default theme styles and colors */
/* It's better to actually copy over default.css into this file (or link to a copy in your child theme) if you're going to do anything outrageous */
@import url('default.css');
/* Prepare theme for plugins */
@import url('../thematic/library/styles/plugins.css');
@import url("http://fonts.googleapis.com/css?family=Libre+Baskerville:400,400italic,700");
body {
background: #fff;
background-image: url("bg.png");
background-repeat: repeat-x;
background-position: top;
}
#wrapper
{
position: absolute;
top: 0px;
width: 1024px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
bottom: 0px;
}
#header
{
position: absolute;
top: 0px;
}
#branding
{
position: absolute;
top: 0px;
width: 1024px;
height: 150px;
background-image: url("monks.png");
background-repeat: no-repeat;
background-position: right;
padding: 0px;
}
#main
{
box-sizing:border-box;
-moz-box-sizing:border-box; /* Firefox */
-webkit-box-sizing:border-box; /* Safari */
position: absolute;
top: 150px;
bottom: 0px;
width: 1024px;
overflow: auto;
padding-left: 20px;
border-left: solid 1px #e6e6e6;
}
#siteinfo
{
visibility:hidden;
}