diff --git a/assets/sass/_keylighter.scss b/assets/sass/_keylighter.scss index 83e96e5..0c8c452 100755 --- a/assets/sass/_keylighter.scss +++ b/assets/sass/_keylighter.scss @@ -1,6 +1,5 @@ $kl-prefix: "kl-"; - -@import "../../vendor/kadet/keylighter/Styles/Html/keylighter"; +@import "keylighter/fallback"; pre.keylighter { background-color: #181818; @@ -55,5 +54,5 @@ code { } $kl-prefix: ""; -@import "../../vendor/kadet/keylighter/Styles/Html/keylighter"; +@import "keylighter/fallback"; diff --git a/assets/sass/keylighter/_utils.scss b/assets/sass/keylighter/_utils.scss new file mode 100644 index 0000000..23f0c0b --- /dev/null +++ b/assets/sass/keylighter/_utils.scss @@ -0,0 +1,18 @@ +$kl-prefix: "kl-" !default; +$kl-tag: "span" !default; +$kl-class: "keylighter" !default; + +@function token($selectors...) { + $result: ""; + + @each $selector in $selectors { + $selector: ".#{$selector}"; + $result: "#{$result}, #{$kl-tag}"; + + @each $token in simple_selectors($selector) { + $result: "#{$result}.#{$kl-prefix}#{str_slice($token, 2)}"; + } + } + + @return str_slice($result, 3); +} diff --git a/assets/sass/keylighter/fallback.scss b/assets/sass/keylighter/fallback.scss new file mode 100644 index 0000000..c769fba --- /dev/null +++ b/assets/sass/keylighter/fallback.scss @@ -0,0 +1,71 @@ +@import "utils"; + +// colors: +$background: #181818; +$foreground: white; + +$red: #E26F90; +$magenta: #D17BCA; +$green: #89B366; +$brown: #99764b; +$violet: #BD9CE0; +$blue: #336CAD; +$orange: #FF9700; +$yellow: #F4BD8C; + +$alt-red: #F5A2B7; +$alt-magenta: #E0A7DC; +$alt-green: #b7e388; +$alt-brown: #ad916f; +$alt-violet: #AD83E2; +$alt-blue: #6691C2; +$alt-orange: #c17200; +$alt-yellow: #ffdebb; + +.#{$kl-class} { + background: $background; + padding: 15px; + + #{token('language', 'expression')} { color: $foreground; } + + #{token('keyword')} { color: $orange; } + #{token('operator')} { color: $alt-orange; } + #{token('delimiter')} { color: $alt-orange; } + #{token('string')} { color: $alt-green; } + #{token('comment')} { color: #555 } + #{token('number')} { color: $red } + #{token('constant')} { color: $alt-red } + #{token('call')} { color: $yellow } + + #{token('call.preprocessor')} { color: $brown } + #{token('preprocessor')} { color: $alt-brown } + + #{token('symbol')} { color: $alt-yellow; } + #{token('variable')} { color: $alt-violet; } + #{token('annotation')} { color: $orange; } + #{token('parameter')} { color: $alt-blue; } + + #{token('annotation.arguments')} { color: $foreground; } + #{token('variable.splat')} { color: $violet; } + #{token('variable.property')} { color: $violet; } + #{token('symbol.dotnet')} { color: $alt-yellow; } + + #{token('comment.docblock')} { color: #666 } + + #{token('tag')} { color: $alt-orange; } + #{token('symbol.tag')} { font-weight: bold } + #{token('attribute')} { color: $yellow; } + + #{token('format.bold')} { font-weight: bold } + #{token('format.italics')} { font-style: italic } + #{token('format.strike')} { text-decoration: line-through } + #{token('format.underline')} { text-decoration: underline } + + #{token('format.monospace', 'format.block.code')} { color: #666 } + + #{token('format.header')} { color: $alt-blue } + #{token('symbol.type')} { color: $alt-red } + + #{token('tag.namespace')} { color: $orange; font-weight: normal } + #{token('attribute.namespace')} { color: $alt-yellow; } +} diff --git a/docker/nginx/keylighter.localhost b/docker/nginx/keylighter.localhost index b1dc962..8a11d55 100644 --- a/docker/nginx/keylighter.localhost +++ b/docker/nginx/keylighter.localhost @@ -6,23 +6,23 @@ server { location / { try_files $uri $uri/ /index.php?$args; - - location ~ \.(js|css)$ { - expires 1y; - } - - location ~ ^/index\.php(/|$) { - fastcgi_pass php:9000; - fastcgi_split_path_info ^(.+\.php)(/.*)$; - - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; - fastcgi_param DOCUMENT_ROOT $realpath_root; - - fastcgi_param APP_ENV "dev"; - fastcgi_param DATABASE_URL "sqlite:///%kernel.project_dir%/var/app.db"; - - internal; - } } + + location /keylighter.css { + try_files $uri $uri/ /index.php?$args; + } + + location ~ ^/index\.php(/|$) { + fastcgi_pass php:9000; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + + fastcgi_param APP_ENV "dev"; + fastcgi_param DATABASE_URL "sqlite:///%kernel.project_dir%/var/app.db"; + + internal; + } } diff --git a/src/Controller/StylesAction.php b/src/Controller/StylesAction.php new file mode 100644 index 0000000..09e2151 --- /dev/null +++ b/src/Controller/StylesAction.php @@ -0,0 +1,43 @@ +versioner = $versioner; + } + + /** + * @Route("/keylighter.css", name="keylighter_stylesheet") + */ + public function __invoke() + { + $path = $this->getCssFilePath(); + + return new Response(file_get_contents($path), Response::HTTP_OK, [ + 'Content-Type' => 'text/css', + ]); + } + + private function getCssFilePath() + { + switch (true) { + case version_compare(KeyLighter::VERSION, '0.9.0', '>='): + $base = $this->versioner->getCurrentDir(); + return sprintf("%s/%s", $base, 'Styles/Html/dist/keylighter.css'); + + default: + $base = $this->versioner->getDirectory('dev-master'); + return sprintf("%s/%s", $base, 'Styles/Html/dist/keylighter.css'); + } + } +} diff --git a/templates/keylighter.html.twig b/templates/keylighter.html.twig index 6fcde8f..7d3ec88 100755 --- a/templates/keylighter.html.twig +++ b/templates/keylighter.html.twig @@ -9,6 +9,7 @@