mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Allow selection of highlight js languages
PERF: stop loading highlight js on load To get latest highlight js run bin/rake highlightjs:update
This commit is contained in:
@@ -32,6 +32,9 @@ module Discourse
|
||||
require 'es6_module_transpiler/rails'
|
||||
require 'js_locale_helper'
|
||||
|
||||
# tiny file needed by site settings
|
||||
require 'highlight_js/highlight_js'
|
||||
|
||||
# mocha hates us, active_support/testing/mochaing.rb line 2 is requiring the wrong
|
||||
# require, patched in source, on upgrade remove this
|
||||
if Rails.env.test? || Rails.env.development?
|
||||
|
||||
@@ -27,6 +27,7 @@ if defined?(Rack::MiniProfiler)
|
||||
(path !~ /assets/) &&
|
||||
(path !~ /\/user_avatar\//) &&
|
||||
(path !~ /\/letter_avatar\//) &&
|
||||
(path !~ /\/highlight-js\//) &&
|
||||
(path !~ /qunit/) &&
|
||||
(path !~ /srv\/status/) &&
|
||||
(path !~ /commits-widget/) &&
|
||||
|
||||
@@ -1104,6 +1104,7 @@ en:
|
||||
default_code_lang: "Default programming language syntax highlighting applied to GitHub code blocks (lang-auto, ruby, python etc.)"
|
||||
warn_reviving_old_topic_age: "When someone starts replying to a topic where the last reply is older than this many days, a warning will be displayed. Disable by setting to 0."
|
||||
autohighlight_all_code: "Force apply code highlighting to all preformatted code blocks even when they didn't explicitly specify the language."
|
||||
highlighted_languages: "Included syntax highlighting rules. (Warning: including too many langauges may impact performance) see: https://highlightjs.org/static/demo/ for a demo"
|
||||
|
||||
embeddable_host: "Host that can embed the comments from this Discourse forum. Hostname only, do not begin with http://"
|
||||
feed_polling_enabled: "EMBEDDING ONLY: Whether to embed a RSS/ATOM feed as posts."
|
||||
|
||||
@@ -158,7 +158,7 @@ server {
|
||||
# This big block is needed so we can selectively enable
|
||||
# acceleration for backups and avatars
|
||||
# see note about repetition above
|
||||
location ~ ^/(letter_avatar|user_avatar) {
|
||||
location ~ ^/(letter_avatar|user_avatar|highlight-js) {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
@@ -274,6 +274,8 @@ Discourse::Application.routes.draw do
|
||||
get "letter_avatar/:username/:size/:version.png" => "user_avatars#show_letter", format: false, constraints: { hostname: /[\w\.-]+/ }
|
||||
get "user_avatar/:hostname/:username/:size/:version.png" => "user_avatars#show", format: false, constraints: { hostname: /[\w\.-]+/ }
|
||||
|
||||
get "highlight-js/:hostname/:version.js" => "highlight_js#show", format: false, constraints: { hostname: /[\w\.-]+/ }
|
||||
|
||||
get "uploads/:site/:id/:sha.:extension" => "uploads#show", constraints: {site: /\w+/, id: /\d+/, sha: /[a-z0-9]{15,16}/i, extension: /\w{2,}/}
|
||||
get "uploads/:site/:sha" => "uploads#show", constraints: { site: /\w+/, sha: /[a-z0-9]{40}/}
|
||||
post "uploads" => "uploads#create"
|
||||
|
||||
@@ -400,6 +400,11 @@ posting:
|
||||
autohighlight_all_code:
|
||||
client: true
|
||||
default: false
|
||||
highlighted_languages:
|
||||
default: 'apache|bash|cs|cpp|css|coffeescript|diff|xml|http|ini|json|java|javascript|makefile|markdown|nginx|objectivec|ruby|perl|php|python|sql|handlebars'
|
||||
choices: 'HighlightJs.languages'
|
||||
type: list
|
||||
client: true
|
||||
delete_old_hidden_posts: true
|
||||
censored_words:
|
||||
client: true
|
||||
|
||||
Reference in New Issue
Block a user