Explorar el Código

Implement syntax highlighting

pull/7/head
Michael Walker hace 9 años
padre
commit
7c7a465966
Se han modificado 7 ficheros con 1980 adiciones y 3 borrados
  1. +10
    -1
      inc/functions.php
  2. +12
    -0
      js/hilight.js
  3. +1655
    -0
      js/prettify.js
  4. +141
    -0
      stylesheets/code/dark.css
  5. +141
    -0
      stylesheets/code/light.css
  6. +1
    -0
      templates/header.html
  7. +20
    -2
      templates/main.js

+ 10
- 1
inc/functions.php Ver fichero

@@ -76,6 +76,7 @@ function loadConfig() {
'file_icons',
'footer',
'stylesheets',
'code_stylesheets',
'additional_javascript',
'markup',
'custom_pages',
@@ -1515,9 +1516,17 @@ function buildJavascript() {
'uri' => addslashes((!empty($uri) ? $config['uri_stylesheets'] : '') . $uri));
}

$code_stylesheets = array();
foreach ($config['code_stylesheets'] as $name => $uri) {
$code_stylesheets[] = array(
'name' => addslashes($name),
'uri' => addslashes((!empty($uri) ? $config['uri_stylesheets'] : '') . $uri));
}

$script = Element('main.js', array(
'config' => $config,
'stylesheets' => $stylesheets
'stylesheets' => $stylesheets,
'code_stylesheets' => $code_stylesheets
));

// Check if we have translation for the javascripts; if yes, we add it to additional javascripts


+ 12
- 0
js/hilight.js Ver fichero

@@ -0,0 +1,12 @@
function styleCode() {
$('pre').each(function() {
if (!$(this).hasClass('prettyprint')) {
$(this).addClass('prettyprint');
}
});

prettyPrint();
}

$(function() {styleCode();});


+ 1655
- 0
js/prettify.js
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 141
- 0
stylesheets/code/dark.css Ver fichero

@@ -0,0 +1,141 @@
/* Tomorrow Night Eighties Theme */
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
.prettyprint {
background: #2d2d2d;
font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace;
font-size: 12px;
line-height: 1.5;
border: 1px solid #ccc;
padding: 10px;
}

.pln {
color: #cccccc;
}

@media screen {
.str {
color: #99cc99;
}

.kwd {
color: #cc99cc;
}

.com {
color: #999999;
}

.typ {
color: #6699cc;
}

.lit {
color: #f99157;
}

.pun {
color: #cccccc;
}

.opn {
color: #cccccc;
}

.clo {
color: #cccccc;
}

.tag {
color: #f2777a;
}

.atn {
color: #f99157;
}

.atv {
color: #66cccc;
}

.dec {
color: #f99157;
}

.var {
color: #f2777a;
}

.fun {
color: #6699cc;
}
}
@media print, projection {
.str {
color: #006600;
}

.kwd {
color: #006;
font-weight: bold;
}

.com {
color: #600;
font-style: italic;
}

.typ {
color: #404;
font-weight: bold;
}

.lit {
color: #004444;
}

.pun, .opn, .clo {
color: #444400;
}

.tag {
color: #006;
font-weight: bold;
}

.atn {
color: #440044;
}

.atv {
color: #006600;
}
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0;
}

/* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L4,
li.L5,
li.L6,
li.L7,
li.L8,
li.L9 {
/* */
}

/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 {
/* */
}

+ 141
- 0
stylesheets/code/light.css Ver fichero

@@ -0,0 +1,141 @@
/* Tomorrow Theme */
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
.prettyprint {
background: white;
font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace;
font-size: 12px;
line-height: 1.5;
border: 1px solid #ccc;
padding: 10px;
}

.pln {
color: #4d4d4c;
}

@media screen {
.str {
color: #718c00;
}

.kwd {
color: #8959a8;
}

.com {
color: #8e908c;
}

.typ {
color: #4271ae;
}

.lit {
color: #f5871f;
}

.pun {
color: #4d4d4c;
}

.opn {
color: #4d4d4c;
}

.clo {
color: #4d4d4c;
}

.tag {
color: #c82829;
}

.atn {
color: #f5871f;
}

.atv {
color: #3e999f;
}

.dec {
color: #f5871f;
}

.var {
color: #c82829;
}

.fun {
color: #4271ae;
}
}
@media print, projection {
.str {
color: #006600;
}

.kwd {
color: #006;
font-weight: bold;
}

.com {
color: #600;
font-style: italic;
}

.typ {
color: #404;
font-weight: bold;
}

.lit {
color: #004444;
}

.pun, .opn, .clo {
color: #444400;
}

.tag {
color: #006;
font-weight: bold;
}

.atn {
color: #440044;
}

.atv {
color: #006600;
}
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin-top: 0;
margin-bottom: 0;
}

/* IE indents via margin-left */
li.L0,
li.L1,
li.L2,
li.L3,
li.L4,
li.L5,
li.L6,
li.L7,
li.L8,
li.L9 {
/* */
}

/* Alternate shading for lines */
li.L1,
li.L3,
li.L5,
li.L7,
li.L9 {
/* */
}

+ 1
- 0
templates/header.html Ver fichero

@@ -4,6 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes">
{% if config.meta_keywords %}<meta name="keywords" content="{{ config.meta_keywords }}">{% endif %}
{% if config.default_stylesheet.1 != '' %}<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}">{% endif %}
{% if config.default_code_stylesheet.1 != '' %}<link rel="stylesheet" type="text/css" id="code_stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_code_stylesheet.1 }}">{% endif %}
{% if config.font_awesome %}<link rel="stylesheet" href="{{ config.root }}{{ config.font_awesome_css }}">{% endif %}
{% if config.country_flags_condensed %}<link rel="stylesheet" href="{{ config.root }}{{ config.country_flags_condensed_css }}">{% endif %}
<script type="text/javascript">


+ 20
- 2
templates/main.js Ver fichero

@@ -31,6 +31,11 @@ var styles = {
{% for stylesheet in stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}',
{% endraw %}{% endfor %}{% raw %}
};
var codestyles = {
{% endraw %}
{% for stylesheet in code_stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}',
{% endraw %}{% endfor %}{% raw %}
};
var board_name = false;

function changeStyle(styleName, link) {
@@ -45,6 +50,7 @@ function changeStyle(styleName, link) {
{% endif %}
{% raw %}
// Main stylesheet
if (!document.getElementById('stylesheet')) {
var s = document.createElement('link');
s.rel = 'stylesheet';
@@ -53,9 +59,21 @@ function changeStyle(styleName, link) {
var x = document.getElementsByTagName('head')[0];
x.appendChild(s);
}
document.getElementById('stylesheet').href = styles[styleName];
selectedstyle = styleName;
selectedstyle = styleName;

// Code stylesheet
if (!document.getElementById('code_stylesheet')) {
var s = document.createElement('link');
s.rel = 'stylesheet';
s.type = 'text/css';
s.id = 'code_stylesheet';
var x = document.getElementsByTagName('head')[0];
x.appendChild(s);
}

document.getElementById('code_stylesheet').href = codestyles[styleName];
if (document.getElementsByClassName('styles').length != 0) {
var styleLinks = document.getElementsByClassName('styles')[0].childNodes;


Cargando…
Cancelar
Guardar