Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lien vers gregoriophp #1

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
scores/
temp/
sources/
include/credentials.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
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
* 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

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
9 changes: 5 additions & 4 deletions chant.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
<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;
Expand Down Expand Up @@ -230,6 +230,7 @@
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";
Expand Down Expand Up @@ -276,7 +277,7 @@
// 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
Expand All @@ -285,7 +286,7 @@
});
$('#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
Expand Down
1 change: 1 addition & 0 deletions chant_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
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";
Expand Down
8 changes: 4 additions & 4 deletions chant_img.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
218 changes: 218 additions & 0 deletions chant_submit.php
Original file line number Diff line number Diff line change
@@ -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);
?>
6 changes: 6 additions & 0 deletions include/credentials.php.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
define("HOST", "localhost"); // The host you want to connect to.
define("USER", "user"); // The database username.
define("PASSWORD", "password"); // The database password.
define("DATABASE", "database"); // The database name.
?>
9 changes: 3 additions & 6 deletions include/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ function chant_from_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['incipit']:'░░░░', $ch['gabc'] > '', $ch['version']);
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.

include('credentials.php');

$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);

$mysqli->query('SET NAMES utf8');
Expand Down
4 changes: 2 additions & 2 deletions include/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<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>
Expand Down
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<head>
<script>location='scores.php';</script>
</head>
</html>