This commit is contained in:
jperon 2014-06-30 10:46:23 +00:00
commit 9374b25020
9 changed files with 266 additions and 12 deletions

25
.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
scores/
temp/
sources/
include/db.php
*~
license.txt
readme.html
index.php
wp-activate.php
wp-admin/
wp-blog-header.php
wp-comments-post.php
wp-config-sample.php
wp-config.php
wp-content/
wp-cron.php
wp-includes/
wp-links-opml.php
wp-load.php
wp-login.php
wp-mail.php
wp-settings.php
wp-signup.php
wp-trackback.php
xmlrpc.php

View File

@ -4,14 +4,14 @@
* A working installation of [WordPress](http://wordpress.org/) (used for user management only)
* [gregorio](https://gna.org/projects/gregorio/)
* [LuaLaTeX](http://www.tug.org/texlive/)
* [ImageMagick](http://www.imagemagick.org/)
* *([ImageMagick](http://www.imagemagick.org/) should not be necessary any more)*
* [PDFCrop](http://pdfcrop.sourceforge.net/)
* [GhostScript](http://www.ghostscript.com/)
### Install
* Copy all GregoBase files into the WordPress directory
* Make sure directories `temp`, `scores`, `scores/pdf`, `scores/png` and `scores/eps` are writeable by the server
* Set your database connection data in `include/db.php`
* Rename `include/db.php.sample` in `include/db.php` and edit it to set your database connection data
* Import `gregobase_structure.sql` into your db
* Add an item to your menu linking to`your_wordpress_install/scores.php` or access it directly
@ -19,5 +19,9 @@ If you want to have a local copy of http://gregobase.selapa.net
* Import `grego_online.sql` into your db (of course the user data aren't in that file so you won't see who made the changes)
If you want to be able to personalize your scores
* Install [gregoriophp](https://github.com/jperon/gregoriophp)
### Limitations
* There's no interface for sources edition yet so you need to add them directly into the database

View File

@ -20,11 +20,11 @@ $custom_header = <<<HEADER
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.bpopup.min.js"></script>
<style>
#popup1, #popup2 {
#popup1, #popup2 {
background-color:#fff;
border-radius:15px;
color:#000;
display:none;
display:none;
padding:20px;
min-width:400px;
min-height: 80px;
@ -230,6 +230,7 @@ if(is_string($content)) {
foreach(array('pdf','eps','png') as $a) {
echo '<li><a href="download.php?id='.$c['id'].'&amp;format='.$a.'">'.strtoupper($a).'</a></li>'."\n";
}
echo '<li><a href="chant_submit.php?id='.$c['id'].'"target="_blank">Suit to your needs</a></li>'."\n";
echo "</ul>\n";
if($c['gabc_verses'] || $c['tex_verses']){
echo "<ul>\n";
@ -276,7 +277,7 @@ echo <<<SCRIPT
// From jQuery v.1.7.0 use .on() instead of .bind()
$('#push1').bind('click', function(e) {
// Prevents the default action to be triggered.
// Prevents the default action to be triggered.
e.preventDefault();
// Triggering bPopup when click event is fired
@ -285,7 +286,7 @@ echo <<<SCRIPT
});
$('#push2').bind('click', function(e) {
// Prevents the default action to be triggered.
// Prevents the default action to be triggered.
e.preventDefault();
// Triggering bPopup when click event is fired

View File

@ -274,6 +274,7 @@ if(!$logged_in) {
echo '<br />&nbsp;</div>'."\n";
echo '<div id="info">
';
echo '<h4>Special characters (to copy/paste)</h4>℟ ℣ † ✠ æ ǽ œ œ́ á é í ó ú ý'."\n";
echo '<h4>Incipit</h4><input name="incipit" value="'.$c['incipit'].'" />'."\n";
echo '<h4>Version</h4><input name="version" value="'.$c['version'].'" />'."\n";
echo '<h4>Usage</h4><select name="office-part">'."\n";

8
chant_img.php Normal file → Executable file
View File

@ -180,12 +180,12 @@ function makeimgfiles($id, $tex, $suffix = '') {
fclose($f[0]);
chdir(dirname($f[1]));
exec('lualatex --interaction=nonstopmode '.basename($f[1]));
exec('convert -density 300 '.substr($f[1],0,-4).'.pdf -flatten -trim '.$path.'png/'.$id.$suffix.'.png');
chmod($path.'png/'.$id.$suffix.'.png', 0666);
exec('convert -resize 33.333333% '.$path.'png/'.$id.$suffix.'.png '.$path.$id.$suffix.'.png');
chmod($path.$id.$suffix.'.png', 0666);
exec('pdfcrop '.substr($f[1],0,-4).'.pdf '.$path.'pdf/'.$id.$suffix.'.pdf');
chmod($path.'pdf/'.$id.$suffix.'.pdf', 0666);
exec('gs -q -dBATCH -dMaxBitmap=50000000 -dNOPAUSE -sDEVICE=bbox -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r300x300 -sOutputFile='.$path.'png/'.$id.$suffix.'.png -- '.$path.'pdf/'.$id.$suffix.'.pdf -c quit');
chmod($path.'png/'.$id.$suffix.'.png', 0666);
exec('gs -q -dBATCH -dMaxBitmap=50000000 -dNOPAUSE -sDEVICE=bbox -sDEVICE=pnggray -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r100x100 -sOutputFile='.$path.$id.$suffix.'.png -- '.$path.'pdf/'.$id.$suffix.'.pdf -c quit');
chmod($path.$id.$suffix.'.png', 0666);
exec('gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -dCompatibilityLevel=1.3 -dEmbedAllFonts=true -dSubsetFonts=true -sOutputFile='.$path.'eps/'.$id.$suffix.'.eps '.$path.'pdf/'.$id.$suffix.'.pdf');
chmod($path.'eps/'.$id.$suffix.'.eps', 0666);
unlink($f[1]);

218
chant_submit.php Normal file
View File

@ -0,0 +1,218 @@
<?php
include('include/db.php');
if(array_key_exists("id", $_GET)) {
$id = intval($_GET['id']);
} else {
die('No id');
}
# function makeimg($c) {
# $tex = mgabc2tex($c);
# if($tex) {
# makeimgfiles($c['id'],$tex);
# }
# if($c['gabc_verses'] || $c['tex_verses']) {
# $tex = mgabc2tex($c,True);
# if($tex) {
# makeimgfiles($c['id'],$tex,'.1verse');
# }
# }
# }
#
# function mkstemp($suffix) {
# # based on http://stackoverflow.com/questions/8970913/create-a-temp-file-with-a-specific-extension-using-php
# $attempts = 238328; // 62 x 62 x 62
# $letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
# $length = strlen($letters) - 1;
#
# for($count = 0; $count < $attempts; ++$count) {
# $random = "";
#
# for($p = 0; $p < 6; $p++) {
# $random .= $letters[mt_rand(0, $length)];
# }
#
# $randomFile = __DIR__.'/temp/'.$random.$suffix;
#
# if( !($fd = @fopen($randomFile, "x+")) )
# continue;
#
# return array($fd,$randomFile);
# }
# return False;
# }
#
# function gregorio($s,$i=1) {
# $f = mkstemp('.gabc');
# fwrite($f[0],"initial-style:".$i.";\n%%\n".$s);
# fclose($f[0]);
# chdir(dirname($f[1]));
# exec('gregorio '.basename($f[1]));
# unlink($f[1]);
# $gf = substr($f[1],0,-5).'.tex';
# $g = fopen($gf,'r');
# $tex = fread($g,filesize($gf));
# fclose($g);
# unlink($gf);
# $tex = substr($tex,0,-12)."\n\\relax\n";
#
# if($i > 0) {
# $tex = '\setspaceafterinitial{2.2mm plus 0em minus 0em}
# \setspacebeforeinitial{2.2mm plus 0em minus 0em}
# '.$tex;
# } else {
# $tex = '\setspaceafterinitial{0pt plus 0em minus 0em}%
# \setspacebeforeinitial{0pt plus 0em minus 0em}%
# '.$tex;
# }
#
# return $tex;
# }
#
# function mgabc2tex($c, $firstverse = False) {
# $ann = array('al' => False,
# 'an' => 'Ant',
# 'ca' => 'Cant',
# 'co' => 'Comm',
# 'gr' => 'Grad',
# 'hy' => 'Hymn',
# 'in' => 'Intr',
# 'im' => False,
# 'ky' => False,
# 'of' => 'Offert',
# 'or' => False,
# 'pr' => False,
# 'ps' => False,
# 're' => 'Resp',
# 'se' => 'Seq',
# 'tr' => 'Tract',
# 'va' => False);
# #
# # Document header
# #
# $tex = '% !TEX TS-program = lualatex
# % !TEX encoding = UTF-8
#
# \documentclass[12pt]{article}
# \usepackage{geometry}
# \geometry{paperwidth=16cm,paperheight=150cm}
# \usepackage{gregoriotex}
# \usepackage{fullpage}
# \usepackage{Tabbing}
#
# \usepackage[latin]{babel}
#
# \usepackage{fontspec}
# \defaultfontfeatures{Ligatures=TeX}
# \setmainfont{Linux Libertine O}
#
# \pagestyle{empty}
# \begin{document}
# \newcommand{\red}[1]{\textcolor{red}{#1}}
# \newcommand{\black}[1]{\textcolor{black}{#1}}
# \setlength{\parindent}{0pt}
#
# \def\greinitialformat#1{
# {\fontsize{38}{38}\selectfont #1}
# }
#
# \def\grebiginitialformat#1{
# {\fontsize{144}{144}\selectfont #1}
# }
#
# \tolerance=9999
# \pretolerance=500
# ';
# if($c['commentary']) {
# $tex .= '\commentary{{\small \emph{'.$c['commentary']."}}}\n";
# $tex .= '\nolinebreak[4]'."\n";
# }
# if($ann[$c['office-part']]) {
# $tex .= '\gresetfirstannotation{\small \textbf{'.$ann[$c['office-part']].".}}\n";
# }
# if($c['mode'] || $c['mode_var']) {
# if($c['mode'] == 'p') {
# $mode = "T. pereg.";
# } else {
# $mode = $c['mode'].($c['mode_var']?' '.$c['mode_var']:'');
# }
# $tex .= '\gresetsecondannotation{\small \textbf{'.$mode.".}}\n";
# }
# #
# # Parsing gabc
# #
# $g = json_decode($c['gabc']);
# $i = $c['initial'];
# if(is_array($g)) {
# foreach($g as $l) {
# if($l[0] == 'gabc') {
# $tex .= gregorio($l[1],$i);
# $i = 0;
# } else {
# $tex .= "\\vspace{10pt}\n".$l[1]."\\par\n";
# }
# }
# } elseif($c['gabc_verses'] && !$firstverse) {
# $tex .= gregorio($g."\n".$c['gabc_verses'],$i);
# } elseif($c['tex_verses'] && !$firstverse) {
# $tex .= gregorio($g,$i);
# $tex .= "\\vspace{10pt}\n".$c['tex_verses']."\\par\n";
# } else {
# $tex .= gregorio($g,$i);
# }
# #
# # Document footer
# #
# $tex .= '
# \end{document}
# ';
# return $tex;
# }
#
# function makeimgfiles($id, $tex, $suffix = '') {
# $path = __DIR__.'/scores/';
# $f = mkstemp('.tex');
# fwrite($f[0],$tex);
# fclose($f[0]);
# chdir(dirname($f[1]));
# exec('lualatex --interaction=nonstopmode '.basename($f[1]));
# exec('convert -density 300 '.substr($f[1],0,-4).'.pdf -flatten -trim '.$path.'png/'.$id.$suffix.'.png');
# chmod($path.'png/'.$id.$suffix.'.png', 0666);
# exec('convert -resize 33.333333% '.$path.'png/'.$id.$suffix.'.png '.$path.$id.$suffix.'.png');
# chmod($path.$id.$suffix.'.png', 0666);
# exec('pdfcrop '.substr($f[1],0,-4).'.pdf '.$path.'pdf/'.$id.$suffix.'.pdf');
# chmod($path.'pdf/'.$id.$suffix.'.pdf', 0666);
# exec('gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=epswrite -dCompatibilityLevel=1.3 -dEmbedAllFonts=true -dSubsetFonts=true -sOutputFile='.$path.'eps/'.$id.$suffix.'.eps '.$path.'pdf/'.$id.$suffix.'.pdf');
# chmod($path.'eps/'.$id.$suffix.'.eps', 0666);
# unlink($f[1]);
# unlink(substr($f[1],0,-4).'.log');
# unlink(substr($f[1],0,-4).'.aux');
# unlink(substr($f[1],0,-4).'.gaux');
# unlink(substr($f[1],0,-4).'.pdf');
# }
#
$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');
}
# makeimg($c);
$content="name:".$c['incipit'].";";
if($c['annotation1'] > ''){
$content=$content."%0A"."annotation:".$c['annotation1'].";";
}
if($c['annotation2'] > ''){
$content=$content."%0A"."annotation:".$c['annotation2'].";%0A";
}
if($c['mode'] > '' and $c['annotation2'] == ''){
$content=$content."%0A"."annotation:".$c['mode'].".;";
}
if($c['commentary'] > ''){
$content=$content."%0A"."commentary:".$c['commentary'].";";
}
$content=$content."%0A"."%25%25"."%0A".json_decode($c['gabc']);
header('HTTP/1.1 301 Moved Permanently');
header('Location: /gregoriophp/?crop=0#'.$content);
?>

View File

@ -33,8 +33,8 @@ echo <<<HEADER2
<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=18">Participate</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>$login$pleasefix</ul></div>
<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="./chant_edit.php">Add score</a></li><li class="page_item"><a href="./?page_id=18">Participate</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>$login$pleasefix</ul></div><
</div><!-- #access -->
</div>
<div id="header_overlay"></div>

5
index.html Normal file
View File

@ -0,0 +1,5 @@
<html>
<head>
<script>location='scores.php';</script>
</head>
</html>