added site files

This commit is contained in:
gribse 2025-05-16 18:49:08 +02:00
parent a6f70a6c78
commit 329148c253
253 changed files with 30486 additions and 0 deletions

View file

@ -0,0 +1,47 @@
<?php
/**
* Generate the EnlighterJS Example Pages
* @author Andi Dittrich
* @license MIT Style X11
*/
function cdnbase($file){
global $argv;
// Local Examples or Webbuild ?
if (isset($argv[2]) && trim($argv[2]) == 'www'){
return basename($file);
}else{
return '../'.$file;
}
}
require('global.php');
// setup metainit string
$metainit = '<meta name="EnlighterJS" content="Advanced javascript based syntax highlighting" data-language="javascript" data-indent="2" data-selector-block="pre" data-selector-inline="code" />';
// === Basic Examples =================================================
renderTemplate($outputDir.'Example1.html', array(
'page' => 'Resources/ExampleData/Example1.phtml',
'pageTitle' => 'Basic EnlighterJS Example',
'header' => $metainit
));
renderTemplate($outputDir.'Example2-jsinit.html', array(
'page' => 'Resources/ExampleData/Example2-jsinit.phtml',
'pageTitle' => 'Javascript Initialization Example',
'header' => ''
));
renderTemplate($outputDir.'Example3-advanced.html', array(
'page' => 'Resources/ExampleData/Example3-advanced.phtml',
'pageTitle' => 'Advanced Javascript Example',
'header' => ''
));
/**
* Renders the template file and return HTML
* @param Array $vars
*/
function renderTemplate($destination, $vars = array()){
file_put_contents($destination, captureTemplate('Resources/ExampleTemplate.phtml', $vars));
}

View file

@ -0,0 +1,78 @@
<?php
/**
* Generate the EnlighterJS Documentation Pages
* @author Andi Dittrich
* @license MIT Style X11
*/
// Get Build Version
define('EJS_VERSION', (count($argv)>=3 ? $argv[2] : 'unknown'));
define('EJS_PACKAGE_ZIP', 'https://github.com/AndiDittrich/EnlighterJS/archive/v' . EJS_VERSION.'.zip');
define('EJS_PACKAGE_TGZ', 'https://github.com/AndiDittrich/EnlighterJS/archive/v' . EJS_VERSION.'.tar.gz');
require('global.php');
// === GETTING STARTED ============================================================
renderTemplate($outputDir.'index.html', array(
'PAGE' => 'Resources/Pages/GettingStarted.phtml',
'title' => 'EnlighterJS',
'subtitle' => 'An OpenSource Syntax Highlighter',
));
// === Changelog ============================================================
renderTemplate($outputDir.'Changelog.html', array(
'PAGE' => 'Resources/Pages/Changelog.phtml',
'title' => 'Changelog',
'subtitle' => 'The History of EnlighterJS',
));
// === Documentation ============================================================
renderTemplate($outputDir.'Documentation.html', array(
'PAGE' => 'Resources/Pages/Documentation.phtml',
'title' => 'Documentation',
'subtitle' => 'Feature Reference',
));
// === Languages ============================================================
foreach ($languageExamples as $currentLanguage) {
renderTemplate($outputDir . 'Language.'.$currentLanguage.'.html', array(
'PAGE' => 'Resources/Pages/Languages.phtml',
'title' => 'Languages',
'subtitle' => 'Build-In Support',
'currentLanguage' => $currentLanguage,
'languageExamples' => $languageExamples,
'themes' => $themes
));
}
// === Themes ============================================================
foreach ($themes as $theme) {
renderTemplate($outputDir . 'Theme.'.$theme.'.html', array(
'PAGE' => 'Resources/Pages/Themes.phtml',
'title' => 'Themes',
'subtitle' => 'Enlighter`s Appearance',
'theme' => $theme,
'themes' => $themes
));
}
// === Builder ============================================================
renderTemplate($outputDir.'Builder.html', array(
'PAGE' => 'Resources/Pages/Builder.phtml',
'title' => 'Builder',
'subtitle' => 'Customized EnlighterJS Packages',
'languages' => $languageDescriptions
));
// === Plugins ============================================================
renderTemplate($outputDir.'Plugins.html', array(
'PAGE' => 'Resources/Pages/Plugins.phtml',
'title' => 'Plugins',
'subtitle' => 'Extend, Integrate'
));
function renderTemplate($destination, $vars = array()){
file_put_contents($destination, captureTemplate('Resources/Web.phtml', $vars));
}

14
EnlighterJS/Util/cli.php Normal file
View file

@ -0,0 +1,14 @@
<?php
include('global.php');
if ($argc < 3){
die('Usage: cli.php command args..');
}
switch ($argv[1]){
case 'markdown':
file_put_contents($argv[3], renderMarkdownDocument($argv[2]));
break;
}

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
clean-css Subtask
Simply concat+compress multiple files
@author Andi Dittrich <andi.dittrich@a3non.org>
@version 2.0
@license MIT Style X11 License
!-->
<project name="css-concat-compress" default="CSS-Build">
<!-- Generate Build -->
<target name="CSS-Build">
<condition property="cleancss" value="cleancss.cmd">
<os family="windows" />
</condition>
<condition property="cleancss" value="cleancss">
<os family="unix" />
</condition>
<!-- Concatenating Files ! -->
<echo message="Concatenating CSS Files.." />
<concat destfile="${uncompress.output}">
<header trim="yes">${cpnotice}</header>
<filelist files="${compress.input}" />
</concat>
<!-- Compressing Files -->
<echo message="Compressing CSS Files.." />
<exec executable="${cleancss}">
<arg line="-o ${compress.output}"></arg>
<arg line="${uncompress.output}"></arg>
</exec>
</target>
</project>

View file

@ -0,0 +1,79 @@
<?php
// Get output dir
$outputDir = (isset($argv) && isset($argv[1]) ? $argv[1] : 'Output/');
// get the sourcefile lists of current build
$sources = new stdClass();
$sources->js = explode(' ', file_get_contents('.tmp/js.txt'));
$sources->css = explode(' ', file_get_contents('.tmp/css.txt'));
// Theme name List
$themes = explode(' ', file_get_contents('.tmp/themes.txt'));
// Language Example List
$languageExamples = array(
'C', 'Cpp', 'CSharp', 'CSS', 'Cython', 'Diff', 'HTML', 'Java', 'Javascript', 'JSON', 'MarkDown', 'NSIS', 'PHP', 'Python', 'Ruby', 'SQL',
'Unit', 'XML', 'RAW', 'NoHighlight', 'AVR-Assembly', 'Ini', 'Rust', 'Shell', 'VHDL', 'Matlab', 'Generic', 'Squirrel', 'LUA', 'Assembly'
);
asort($languageExamples);
// all languages
$languageList = explode(' ', file_get_contents('.tmp/languages.txt'));
$languageDescriptions = array();
foreach ($languageList as $l){
// get file content
$f = file_get_contents('Source/Language/'.$l.'.js');
// extract description from header
preg_match('/^\s*description\:(.*)$/mi', $f, $matches);
if (count($matches) == 2){
$languageDescriptions[$l] = trim($matches[1]);
}
}
/**
* @param $file
* @param array $vars
* @return string
*/
function captureTemplate($file, $vars = array()){
// exapand vars to local variables
extract($vars);
// start capturing
ob_start();
// load local template file
require($file);
// store captured content
$_generatedContent = ob_get_clean();
return $_generatedContent;
}
/**
* Render a Markdown Document using LightUp with Promethium CloudAPI
* @param unknown $content
*/
function renderMarkdownDocument($filename){
$content = file_get_contents($filename);
$postdata = http_build_query(array(
'mddata' => $content,
'highlightingMode' => 'enlighterjs',
'addAnchors' => 'false'
));
$opts = array(
'http' => array (
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$htmlContent = file_get_contents('http://promethium.andidittrich.de/lightup/', false, stream_context_create($opts));
// remove first heading1
return preg_replace('/<h1>.*<\/h1>/', '', $htmlContent, 1);
}

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
UglifyJS2 Subtask
Simply concat+compress multiple files
@author Andi Dittrich <andi.dittrich@a3non.org>
@version 2.0
@license MIT Style X11 License
!-->
<project name="js-concat-compress" default="Javascript-Build">
<!-- Generate Build -->
<target name="Javascript-Build">
<condition property="uglifyjs" value="uglifyjs.cmd">
<os family="windows" />
</condition>
<condition property="uglifyjs" value="uglifyjs">
<os family="unix" />
</condition>
<!-- Beautified Version -->
<echo message="Generating beautified version.." />
<exec executable="${uglifyjs}">
<arg line="--beautify"></arg>
<arg line="--comments all"></arg>
<arg line="--enclose"></arg>
<arg line="--preamble"></arg>
<arg value="${cpnotice}"></arg>
<arg line="--output ${uncompress.output}"></arg>
<arg line="--"></arg>
<arg line="${compress.input}"></arg>
</exec>
<!-- Compressed Version -->
<echo message="Generating minified version.." />
<exec executable="${uglifyjs}">
<arg line="--compress"></arg>
<arg line="--mangle"></arg>
<arg line="--enclose"></arg>
<arg line="--preamble"></arg>
<arg value="${cpnotice}"></arg>
<arg line="--output ${compress.output}"></arg>
<arg line="--"></arg>
<arg line="${compress.input}"></arg>
</exec>
</target>
</project>