View | Details | Raw Unified | Return to bug 22584
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/lib/codemirror/yaml.js (+121 lines)
Line 0 Link Here
1
/* CodeMirror version: 5.40.2 */
2
// CodeMirror, copyright (c) by Marijn Haverbeke and others
3
// Distributed under an MIT license: https://codemirror.net/LICENSE
4
5
(function(mod) {
6
  if (typeof exports == "object" && typeof module == "object") // CommonJS
7
    mod(require("../../lib/codemirror"));
8
  else if (typeof define == "function" && define.amd) // AMD
9
    define(["../../lib/codemirror"], mod);
10
  else // Plain browser env
11
    mod(CodeMirror);
12
})(function(CodeMirror) {
13
"use strict";
14
15
CodeMirror.defineMode("yaml", function() {
16
17
  var cons = ['true', 'false', 'on', 'off', 'yes', 'no'];
18
  var keywordRegex = new RegExp("\\b(("+cons.join(")|(")+"))$", 'i');
19
20
  return {
21
    token: function(stream, state) {
22
      var ch = stream.peek();
23
      var esc = state.escaped;
24
      state.escaped = false;
25
      /* comments */
26
      if (ch == "#" && (stream.pos == 0 || /\s/.test(stream.string.charAt(stream.pos - 1)))) {
27
        stream.skipToEnd();
28
        return "comment";
29
      }
30
31
      if (stream.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))
32
        return "string";
33
34
      if (state.literal && stream.indentation() > state.keyCol) {
35
        stream.skipToEnd(); return "string";
36
      } else if (state.literal) { state.literal = false; }
37
      if (stream.sol()) {
38
        state.keyCol = 0;
39
        state.pair = false;
40
        state.pairStart = false;
41
        /* document start */
42
        if(stream.match(/---/)) { return "def"; }
43
        /* document end */
44
        if (stream.match(/\.\.\./)) { return "def"; }
45
        /* array list item */
46
        if (stream.match(/\s*-\s+/)) { return 'meta'; }
47
      }
48
      /* inline pairs/lists */
49
      if (stream.match(/^(\{|\}|\[|\])/)) {
50
        if (ch == '{')
51
          state.inlinePairs++;
52
        else if (ch == '}')
53
          state.inlinePairs--;
54
        else if (ch == '[')
55
          state.inlineList++;
56
        else
57
          state.inlineList--;
58
        return 'meta';
59
      }
60
61
      /* list seperator */
62
      if (state.inlineList > 0 && !esc && ch == ',') {
63
        stream.next();
64
        return 'meta';
65
      }
66
      /* pairs seperator */
67
      if (state.inlinePairs > 0 && !esc && ch == ',') {
68
        state.keyCol = 0;
69
        state.pair = false;
70
        state.pairStart = false;
71
        stream.next();
72
        return 'meta';
73
      }
74
75
      /* start of value of a pair */
76
      if (state.pairStart) {
77
        /* block literals */
78
        if (stream.match(/^\s*(\||\>)\s*/)) { state.literal = true; return 'meta'; };
79
        /* references */
80
        if (stream.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i)) { return 'variable-2'; }
81
        /* numbers */
82
        if (state.inlinePairs == 0 && stream.match(/^\s*-?[0-9\.\,]+\s?$/)) { return 'number'; }
83
        if (state.inlinePairs > 0 && stream.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/)) { return 'number'; }
84
        /* keywords */
85
        if (stream.match(keywordRegex)) { return 'keyword'; }
86
      }
87
88
      /* pairs (associative arrays) -> key */
89
      if (!state.pair && stream.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^,\[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)) {
90
        state.pair = true;
91
        state.keyCol = stream.indentation();
92
        return "atom";
93
      }
94
      if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; }
95
96
      /* nothing found, continue */
97
      state.pairStart = false;
98
      state.escaped = (ch == '\\');
99
      stream.next();
100
      return null;
101
    },
102
    startState: function() {
103
      return {
104
        pair: false,
105
        pairStart: false,
106
        keyCol: 0,
107
        inlinePairs: 0,
108
        inlineList: 0,
109
        literal: false,
110
        escaped: false
111
      };
112
    },
113
    lineComment: "#",
114
    fold: "indent"
115
  };
116
});
117
118
CodeMirror.defineMIME("text/x-yaml", "yaml");
119
CodeMirror.defineMIME("text/yaml", "yaml");
120
121
});
(-)a/koha-tmpl/intranet-tmpl/lib/codemirror/yaml.min.js (+1 lines)
Line 0 Link Here
1
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("yaml",function(){var e=new RegExp("\\b(("+["true","false","on","off","yes","no"].join(")|(")+"))$","i");return{token:function(i,t){var r=i.peek(),n=t.escaped;if(t.escaped=!1,"#"==r&&(0==i.pos||/\s/.test(i.string.charAt(i.pos-1))))return i.skipToEnd(),"comment";if(i.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))return"string";if(t.literal&&i.indentation()>t.keyCol)return i.skipToEnd(),"string";if(t.literal&&(t.literal=!1),i.sol()){if(t.keyCol=0,t.pair=!1,t.pairStart=!1,i.match(/---/))return"def";if(i.match(/\.\.\./))return"def";if(i.match(/\s*-\s+/))return"meta"}if(i.match(/^(\{|\}|\[|\])/))return"{"==r?t.inlinePairs++:"}"==r?t.inlinePairs--:"["==r?t.inlineList++:t.inlineList--,"meta";if(t.inlineList>0&&!n&&","==r)return i.next(),"meta";if(t.inlinePairs>0&&!n&&","==r)return t.keyCol=0,t.pair=!1,t.pairStart=!1,i.next(),"meta";if(t.pairStart){if(i.match(/^\s*(\||\>)\s*/))return t.literal=!0,"meta";if(i.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i))return"variable-2";if(0==t.inlinePairs&&i.match(/^\s*-?[0-9\.\,]+\s?$/))return"number";if(t.inlinePairs>0&&i.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/))return"number";if(i.match(e))return"keyword"}return!t.pair&&i.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^,\[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)?(t.pair=!0,t.keyCol=i.indentation(),"atom"):t.pair&&i.match(/^:\s*/)?(t.pairStart=!0,"meta"):(t.pairStart=!1,t.escaped="\\"==r,i.next(),null)},startState:function(){return{pair:!1,pairStart:!1,keyCol:0,inlinePairs:0,inlineList:0,literal:!1,escaped:!1}},lineComment:"#",fold:"indent"}}),e.defineMIME("text/x-yaml","yaml"),e.defineMIME("text/yaml","yaml")});
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt (+1 lines)
Lines 171-176 Link Here
171
    [% Asset.js( "lib/codemirror/css.min.js" ) | $raw %]
171
    [% Asset.js( "lib/codemirror/css.min.js" ) | $raw %]
172
    [% Asset.js( "lib/codemirror/javascript.min.js" ) | $raw %]
172
    [% Asset.js( "lib/codemirror/javascript.min.js" ) | $raw %]
173
    [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
173
    [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
174
    [% Asset.js( "lib/codemirror/yaml.min.js" ) | $raw %]
174
    <script>
175
    <script>
175
        var Sticky;
176
        var Sticky;
176
        $(document).ready(function(){
177
        $(document).ready(function(){
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +1 lines)
Lines 606-611 OPAC: Link Here
606
        -
606
        -
607
            - pref: OpacHiddenItems
607
            - pref: OpacHiddenItems
608
              type: textarea
608
              type: textarea
609
              syntax: text/x-yaml
609
              class: code
610
              class: code
610
            - Define custom rules to hide specific items from search and view on the OPAC. How to write these rules is documented on the <a href="http://wiki.koha-community.org/wiki/OpacHiddenItems" target="_blank">Koha wiki</a>.
611
            - Define custom rules to hide specific items from search and view on the OPAC. How to write these rules is documented on the <a href="http://wiki.koha-community.org/wiki/OpacHiddenItems" target="_blank">Koha wiki</a>.
611
        -
612
        -
612
- 

Return to bug 22584