-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…t:9702401] * poem Web server - automatically re-generate poem images (prevent copy-paste) * Uses Phantomjs * Code date: 14-15 August 2017.
- Loading branch information
Showing
9 changed files
with
165 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,9 @@ node_modules | |
.jshint* | ||
.env | ||
|
||
/pix | ||
|
||
phantomjs | ||
rasterize.js | ||
|
||
#End. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
if ( php_sapi_name() === 'cli' ) die('Direct access not allowed. Exiting'); | ||
|
||
/** | ||
* A quick & dirty "poem server". | ||
* | ||
* php -S localhost:8000 bin/www-poem.php | ||
* | ||
* @package auth_ouopenid | ||
* @author Nick Freear, 16-August-2017. | ||
* @copyright (c) 2017 The Open University. | ||
*/ | ||
|
||
// Direct include - don't use Moodle "get_string" ! | ||
require_once __DIR__ . '/../lang/en/local_oupilot_poem.php'; | ||
|
||
define( 'STRING_ID', filter_input( INPUT_GET, 'id', FILTER_SANITIZE_STRING )); | ||
define( 'SERIF', filter_input( INPUT_GET, 'serif', FILTER_VALIDATE_BOOLEAN )); | ||
|
||
$poem = STRING_ID && isset($string[ STRING_ID ]) ? $string[ STRING_ID ] : null; | ||
|
||
if (! $poem) { | ||
header( 'HTTP/1.1 404 Not Found', 404 ); | ||
?> Poem / text not found. <?php | ||
exit; | ||
} | ||
|
||
?><!doctype html> <meta charset="utf-8"> <title> Poem (<?php echo STRING_ID ?>) </title> | ||
|
||
<style> | ||
body { margin: 4px; color: #333; font: 1.1em <?php echo SERIF ? 'Georgia,' : 'sans-' ?>serif; } | ||
p { margin: 0; line-height: 1.2em; letter-spacing: .01em; } | ||
.verse { margin-top: .7em; } | ||
.v1 { margin: 0; } | ||
.in { text-indent: 1em; } | ||
h1 { font: 1.5em sans-serif; margin: .5em 0; } | ||
</style> | ||
|
||
<?php echo $poem ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* POEMs! Language strings. | ||
* | ||
* @package auth_ouopenid | ||
* @author Nick Freear, 16-August-2017. | ||
* @copyright (c) 2017 The Open University. | ||
*/ | ||
|
||
// Poem 1 ~~ 'IF'. | ||
$string[ 'poem_1_title' ] = 'If—, by Rudyard Kipling'; | ||
$string[ 'poem_1_url' ] = 'https://www.poetryfoundation.org/poems/46473/if---'; | ||
$string[ 'poem_1' ] = <<<EOT | ||
<h1> If—, by Rudyard Kipling </h1> | ||
<p class="verse v1">If you can keep your head when all about you | ||
<p class="in">Are losing theirs and blaming it on you, | ||
<p> If you can trust yourself when all men doubt you, | ||
<p class="in">But make allowance for their doubting too; | ||
<p> If you can wait and not be tired by waiting, | ||
<p class="in">Or being lied about, don’t deal in lies, | ||
<p> Or being hated, don’t give way to hating, | ||
<p class="in">And yet don’t look too good, nor talk too wise: | ||
<p class="verse">If you can dream—and not make dreams your master; | ||
<p class="in">If you can think—and not make thoughts your aim; | ||
<p> If you can meet with Triumph and Disaster | ||
<p class="in">And treat those two impostors just the same; | ||
<p> If you can bear to hear the truth you’ve spoken | ||
<p class="in">Twisted by knaves to make a trap for fools, | ||
<p> Or watch the things you gave your life to, broken, | ||
<p class="in">And stoop and build ’em up with worn-out tools: | ||
<p class="verse">If you can make one heap of all your winnings | ||
<p class="in">And risk it on one turn of pitch-and-toss, | ||
<p> And lose, and start again at your beginnings | ||
<p class="in">And never breathe a word about your loss; | ||
<p> If you can force your heart and nerve and sinew | ||
<p class="in">To serve your turn long after they are gone, | ||
<p> And so hold on when there is nothing in you | ||
<p class="in">Except the Will which says to them: ‘Hold on!’ | ||
<p class="verse">If you can talk with crowds and keep your virtue, | ||
<p class="in">Or walk with Kings—nor lose the common touch, | ||
<p> If neither foes nor loving friends can hurt you, | ||
<p class="in">If all men count with you, but none too much; | ||
<p> If you can fill the unforgiving minute | ||
<p class="in">With sixty seconds’ worth of distance run, | ||
<p> Yours is the Earth and everything that’s in it, | ||
<p class="in">And—which is more—you’ll be a Man, my son! | ||
EOT; | ||
|
||
$string[ 'poem_2' ] = <<<EOT | ||
<p> Poem 2 ... | ||
EOT; | ||
// End. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters