Skip to content

Commit

Permalink
#257 - fixing broken support for Luminous by updating the API call an…
Browse files Browse the repository at this point in the history
…d loading in the correct CSS files once Luminous is being used as the code highlighter
  • Loading branch information
alphadevx committed Jan 5, 2016
1 parent 6659153 commit 65df5c0
Show file tree
Hide file tree
Showing 4 changed files with 311 additions and 5 deletions.
15 changes: 11 additions & 4 deletions Alpha/Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,18 @@ public function during_displayPageHead_callback()

$params = $this->request->getParams();

$html = '';

if ($config->get('cms.highlight.provider.name') == 'Alpha\Util\Code\Highlight\HighlightProviderLuminous') {
$html .= '<link rel="StyleSheet" type="text/css" href="'.$config->get('app.url').'/css/luminous.css">';
$html .= '<link rel="StyleSheet" type="text/css" href="'.$config->get('app.url').'/css/luminous_light.css">';
}

if ((isset($params['view']) && $params['view'] == 'edit') || (isset($params['ActiveRecordType']) && !isset($params['ActiveRecordOID']))) {
$config = ConfigProvider::getInstance();

$fieldid = ($config->get('security.encrypt.http.fieldnames') ? 'text_field_'.base64_encode(SecurityUtils::encrypt('content')).'_0' : 'text_field_content_0');

$html = '
$html .= '
<script type="text/javascript">
$(document).ready(function() {
$(\'[id="'.$fieldid.'"]\').pagedownBootstrap({
Expand All @@ -467,10 +473,11 @@ public function during_displayPageHead_callback()
});
</script>';

return $html;
} elseif (isset($params['view']) && $params['view'] == 'print') {
return '<link rel="StyleSheet" type="text/css" href="'.$config->get('app.url').'/css/print.css">';
$html .= '<link rel="StyleSheet" type="text/css" href="'.$config->get('app.url').'/css/print.css">';
}

return $html;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion Alpha/Util/Code/Highlight/HighlightProviderLuminous.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Alpha\Util\Code\Highlight;

use luminous;

/**
* Wraps Luminous in the standard API defined in HighlightProviderInterface,
* for use in the Alpha CMS module.
Expand Down Expand Up @@ -52,7 +54,7 @@ class HighlightProviderLuminous implements HighlightProviderInterface
*/
public function highlight($source, $language)
{
$codeblock = luminous($language, $source, false);
$codeblock = luminous::highlight($language, $source, false);

return $codeblock;
}
Expand Down
134 changes: 134 additions & 0 deletions public/css/luminous.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
.luminous {
font-size: inherit;
text-align: left;
font-family: "Consolas", "DejaVu Sans Mono", monospace;
overflow: auto;
border: 2px solid #dddddd;
border-radius: 5px;
position: relative;
/* line numbers */ }
.luminous.inline {
min-width: 1px;
max-width: none;
line-height: normal; }
.luminous.inline, .luminous.inline div, .luminous.inline pre {
padding: 0;
*display: inline;
display: inline-block; }
.luminous.inline pre {
overflow: visible; }
.luminous .link, .luminous .link:visited {
text-decoration: underline; }
.luminous .link:hover {
text-decoration: none; }
.luminous pre {
margin: 0;
padding: 0;
background: transparent none;
font-size: inherit;
font-family: inherit;
width: auto; }
.luminous > pre {
padding-left: 1em; }
.luminous table {
width: 100%;
vertical-align: top;
border-collapse: collapse;
border-spacing: 0; }
.luminous table td {
padding: 0;
margin: 0;
vertical-align: top; }
.luminous table td.code-container {
width: 100%; }
.luminous table .code {
transition-property: padding-left;
transition-duration: 0.2s;
transition-timing-function: ease-in;
-webkit-transition-property: padding-left;
-webkit-transition-duration: 0.2s;
-webkit-transition-timing-function: ease-in;
-moz-transition-property: padding-left;
-moz-transition-duration: 0.2s;
-moz-transition-timing-function: ease-in;
-o-transition-property: padding-left;
-o-transition-duration: 0.2s;
-o-transition-timing-function: ease-in;
-ms-transition-property: padding-left;
-ms-transition-duration: 0.2s;
-ms-transition-timing-function: ease-in; }
.luminous table .code > span {
padding: 0 0 0 1em;
display: block;
transition-property: background-color;
transition-duration: 0.5s;
transition-timing-function: ease-in;
-webkit-transition-property: background-color;
-webkit-transition-duration: 0.5s;
-webkit-transition-timing-function: ease-in;
-moz-transition-property: background-color;
-moz-transition-duration: 0.5s;
-moz-transition-timing-function: ease-in;
-o-transition-property: background-color;
-o-transition-duration: 0.5s;
-o-transition-timing-function: ease-in;
-ms-transition-property: background-color;
-ms-transition-duration: 0.5s;
-ms-transition-timing-function: ease-in; }
.luminous table .line-numbers {
cursor: default;
text-align: center;
overflow: hidden;
max-width: 60px;
transition-property: max-width;
transition-duration: 0.2s;
transition-timing-function: ease-in;
-webkit-transition-property: max-width;
-webkit-transition-duration: 0.2s;
-webkit-transition-timing-function: ease-in;
-moz-transition-property: max-width;
-moz-transition-duration: 0.2s;
-moz-transition-timing-function: ease-in;
-o-transition-property: max-width;
-o-transition-duration: 0.2s;
-o-transition-timing-function: ease-in;
-ms-transition-property: max-width;
-ms-transition-duration: 0.2s;
-ms-transition-timing-function: ease-in; }
.luminous table .line-numbers span {
padding: 0 0.5em;
display: block; }
.luminous table .line-numbers span:nth-child(5n) {
font-weight: bold; }
.luminous table .line-numbers.collapsed {
border: none;
max-width: 0; }
.luminous div {
border-radius: inherit; }
.luminous .line-number-control {
transition-property: left;
transition-duration: 0.2s;
transition-timing-function: ease-in;
-webkit-transition-property: left;
-webkit-transition-duration: 0.2s;
-webkit-transition-timing-function: ease-in;
-moz-transition-property: left;
-moz-transition-duration: 0.2s;
-moz-transition-timing-function: ease-in;
-o-transition-property: left;
-o-transition-duration: 0.2s;
-o-transition-timing-function: ease-in;
-ms-transition-property: left;
-ms-transition-duration: 0.2s;
-ms-transition-timing-function: ease-in;
height: 26px;
width: 18px;
display: block;
position: absolute;
top: 0;
right: 0;
z-index: 1;
cursor: pointer;
background: transparent url(icons/chevron-left.png); }
.luminous .line-number-control.show-line-numbers {
background: transparent url(icons/chevron-right.png); }
163 changes: 163 additions & 0 deletions public/css/luminous_light.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
.luminous .character{color:#FF69B4 !important;}

.luminous .comment{color:gray !important; font-style:italic !important;}

/* NOTE: TODO: etc. */
.luminous .comment_note{
background-color:#FFB2B0 !important;
background-color:rgba(255, 178, 176, 0.70) !important;
color:black !important;
font-style:normal !important;}
.luminous .constant{color:#0073AD !important; font-weight:bold !important;}
.luminous .esc{color:#057CA3 !important;}
.luminous .function{color:purple !important;}
.luminous .heredoc{color:red !important;
background-color:#FFF8F8 !important;
background-color:rgba(255, 248, 248, 0.20) !important;


}
.luminous .htmltag{font-weight:bold !important; color:purple !important;}
.luminous .keyword{font-weight:bold !important; color:#0066FF !important;}
.luminous .numeric {color:blue !important;}
.luminous .operator{color:#0000BF !important;}

.luminous .oo{color:#339900 !important;}
.luminous .obj{color:#3366FF !important;}
.luminous .preprocessor{color:green !important;}
.luminous .shebang{font-weight:bold !important; font-style:normal !important; color:purple !important;}
.luminous .string{color:red !important;
background-color:#FFF8F8 !important;
background-color:rgba(255, 157, 157, 0.20) !important;

}
.luminous .type{color:#0057AE !important;}
/* not used*/
.luminous .user_function{color: #000099 !important; font-weight:bold !important;}
.luminous .value{color:green !important;}
.luminous .variable{color:#4545A9 !important;}

.luminous .doccomment{color:blue !important;}
.luminous .doctag {color:#CA60CA !important;}
.luminous .docstr {color:red !important;}
.luminous .docproperty{color:#0095FF !important; font-weight:bold !important;}



.luminous .lang_latex{color:blue !important;}
.luminous .latex_function{color:red !important; font-weight:normal !important;}
.luminous .latex_operator{color:black !important;}

.luminous .make_target{color:magenta !important;}
.luminous .make_dep{color: blue !important;}

.luminous .regex{color:#8000FF !important;
background-color:#F9F3FF !important;
background-color:rgba(231, 206, 255, 0.20) !important;
}
.luminous .regex_subpattern{font-weight:bold !important; color:black !important;}
.luminous .regex_class_marker{color:#0083E1 !important; font-weight:bold !important;}
.luminous .regex_subpattern_marker{color:green !important; font-weight:bold !important;}
.luminous .regex_repeat_marker {color:blue !important;}
.luminous .regex_operator{color:green !important;}

/* Specific to the whitespace language */
.luminous .whitespace_space{background-color:#FF5151 !important;}
.luminous .whitespace_tab{background-color:#A1B6FF !important;}




.luminous .diff_header_new{color:green !important;}
.luminous .diff_header_old{color:red !important;}
.luminous .diff_range{color:blue !important;}
.luminous .diff_old{background-color:#FFBFBF !important;
background-color: rgba(255, 191, 191, 0.5) !important;
}
.luminous .diff_new{background-color:#BFFFBF !important;
background-color: rgba(191, 255, 191, 0.5) !important;
}
.luminous .diff_unchanged{
color: #888888 !important;

}

.luminous .diff_unchanged * {
background-color: transparent !important;
color: #888888 !important;
}


.luminous .xml {
color: #666 !important;
}
.luminous .xml * {
color: black !important;
}
.luminous .xml .type {
color: #2C72C7 !important;
}
.luminous .xml .htmltag {
color: #00892C !important;
/* font-weight: normal !important; */
}
.luminous .xml .string {
color: #0057AE !important;
}
.luminous .xml .comment {
color: gray !important;
}


.luminous .interpolation * {
background-color: transparent !important;
}
.luminous .interpolation {
font-style: italic;
background-color: rgba(30, 80, 200, 0.1);
}

.luminous .delimiter {
font-weight:bold;
color: #644A9B;
}


.luminous .code
{
background-color: #FCFCFC !important;
}

.luminous a.link, .luminous a.link:visited
{
color:blue !important;
}

/* line numbers */
.luminous .line-numbers{
color:black !important;
background-color:#e0e0e0 !important;
border-right:1px solid black !important;
}
.luminous
{
color:black !important;
border-color: #999;
background-color: #fff;
}



.luminous .code.numbered > span:nth-child(2n)
{
background-color:#F3F3F3;
}

.luminous .code .highlight
{
background-color:#DFDEF6;
}
.luminous .code.numbered .highlight:nth-child(2n)
{
background-color:#DFDEF6;
}

0 comments on commit 65df5c0

Please sign in to comment.