Menu:

plugin for including local source code

SourceCode Plugin

With the SourceCode Plugin you can integrate the source code of a local file into your CMS page.

Example tag:

HTML
1
{% lucidTag SourceCode url="./media/PyLucid/install_views.css" %}

Note: With the <code>-Tag you can directly put highlight source code into your CMS page, look at <code>-Tag

PyLucid used the Python syntax highlighter Pygments . It supports an ever-growing range of languages, look at: http://pygments.pocoo.org/docs/lexers/

some Examples:

./media/PyLucid/install_views.css:

CSS
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
    Stylesheet for the _install section views.
    Used in ./PyLucid/templates_PyLucid/install_base.html
*/
form * {
  vertical-align:middle;
}
input {
    border: 1px solid #C9C573;
    margin: 0.4em;
}
pre {
    background-color: #FFFFFF;
    padding: 1em;
}
#menu li, #menu li a {
    list-style-type: none;
    padding: 0.3em;
}
#menu h4 {
    margin: 0px;
}
a {
    color:#0BE;
    text-decoration:none;
    padding: 0.1em;
}
a:hover {
    color:#000000;
    text-decoration:underline;
    background-color: #F4F4D2;
}
fieldset.error {
    border:2px solid red;
}
.help_text, .page_stats {
    font-size:0.8em;
}
#hash {
    background-color: grey;
}
#source, #source:active, #source:hover, #source:focus {
    background-color: white;
}
.footer, .header {
    text-align:center;
    background-color: white;
    line-height:2em;
}
.footer a {
    border:1px solid #f0f0f0;
    margin: 0.5em;
    padding: 0.2em;
}
.page_stats {
    padding-top:1em;
    text-align:right;
    font-weight:lighter;
}

./media/PyLucid/shared_sha_tools.js:

JavaScript
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/* ___________________________________________________________________________
 *  Some needed stuff round the SHA-JS-Login
 */

check_ok = false;
debug_msg = false;

// length of a SHA1 hexdigest string:
HASH_LEN = 40;
// length of the salt and challenge value string:
SALT_LEN = 5;


if (!document.getElementById) {
    alert("Error: Your Browser is not supported!");
}

if (navigator.cookieEnabled) {
    if (navigator.cookieEnabled != true) {
        alert("You must enable Cookies in your Browser!");
    }
}

/* ___________________________________________________________________________
 *  needfull generic functions:
 */

function get_value(object_id) {
    // get a form value
    try {
        return document.getElementById(object_id).value;
    } catch (e) {
        alert("get_value('"+object_id+"') error! " + e);
    }
}

function set_value(object_id, value) {
    // set a form value
    try {
        obj = document.getElementById(object_id).value = value;
    } catch (e) {
        alert("set_value('"+object_id+"', '"+value+"') error! " + e);
    }
}

function set_focus(object_id) {
    try {
        debug("set focus on id:" + object_id);
        document.getElementById(object_id).focus();
    } catch (e) {
        alert("set_focus('"+object_id+"') error:" + e);
    }
}

function hide_by_id(object_id) {
    try {
        debug("hide_by_id: "+object_id);
        obj = document.getElementById(object_id);
        obj.style.display = 'none';
    } catch (e) {
        alert("hide_by_id('"+object_id+"') error:" + e);
    }
}
function unhide_by_id(object_id) {
    try {
        debug("unhide_by_id: "+object_id);
        obj = document.getElementById(object_id);
        obj.style.display = 'block';
    } catch (e) {
        alert("unhide_by_id('"+object_id+"') error:" + e);
    }
}

function change_color(object_id, color_name) {
    try {
        debug("change_color: "+object_id);
        obj = document.getElementById(object_id);
        obj.style.backgroundColor = color_name;
    } catch (e) {
        alert("change_color('"+object_id+"', '"+color_name+"') error:" + e);
    }
}

/* ___________________________________________________________________________
 *  special functions:
 */

function check_ascii_only(data) {
    for (var i = 1; i <= data.length; i++) {
       unicode_charcode = data.charCodeAt(i);
       if (unicode_charcode > 127) {
            alert("Only ASCII letters are allowed!");
            return false;
       }
    }
    return true;
 }

function get_plaintext_pass(object_id) {
    try {
        in_pass = get_value(object_id);
        debug("in_pass:" + in_pass);
        if (in_pass.length<8) {
            alert("Password min len 8! - current len:" + in_pass.length);
            set_focus(object_id)
            return false;
        }

        if (check_ascii_only(in_pass) == false) {
            set_focus(object_id)
            return false;
        }
        return in_pass;
    } catch (e) {
        alert("get_plaintext_pass() error:" + e);
        return false;
    }
}

function make_SHA(txt) {
    try {
        debug("make_SHA(" + txt + "):");
        SHA_hexdigest = hex_sha1(txt); // from: sha.js
        len = SHA_hexdigest.length;
        if (len != HASH_LEN) {
            alert("make_SHA() error! wrong length:" + len);
            return false;
        }
        debug(SHA_hexdigest);
        return SHA_hexdigest;
    } catch (e) {
        alert("make_SHA() error:" + e);
        return false;
    }
}


/* ___________________________________________________________________________
 *  debugging:
 */

function init_debug() {
    /* Create a debug window, if it's not exists */
    try {
        if (debug_msg != true) { return; }
        try {
            if (debug_window) {
                return;
            }
        } catch (e) {}
        debug_window = window.open("", "Debug", "dependent=yes, resizable=yes, scrollbars=yes, width=350, height=400, top=1, left=" + window.outerWidth);

        debug_win = debug_window.document;
        debug_win.writeln("<style>* { font-size: 0.85em; }</style>");

        var now = new Date();
        now = now.toLocaleString();

        debug_win.writeln("<h1>JS Debug - "+now+":</h1>");
        debug_win.writeln("---[DEBUG START]---");
        debug_win.writeln("cookie:" + document.cookie +"<br />");
    } catch (e) {
        alert("init_debug() error:" + e);
    }
}


function debug(msg) {
    try {
        if (debug_msg != true) { return; }
        init_debug();
        debug_win.writeln(msg + "<br />");
        debug_window.focus();
        // scroll to the last lines
        debug_window.scrollBy(0, 1000);
    } catch (e) {
        alert("debug('"+msg+"') error:" + e);
    }
}


function debug_confirm() {
    try {
       if (debug_msg != true) { return; }
       debug_window.focus();
       debug_win.writeln("---[DEBUG END]---");
       alert("OK for closing the debug window.");
       debug_window.close();
       debug_window = false;
    } catch (e) {
        alert("debug_confirm() error:" + e);
    }
}

<code>-Tag

Use <code=ext>...</code> and PyLucid used Pygments to highlight it.
'ext' is the typical fileextension/alias, please look at:

examples

<code=css>
.xs {font-family:verdana,arial,helvetica,sans-serif;font-size: x-small}
.m {font-size: medium}
</code>

result:

CSS
1
2
.xs {font-family:verdana,arial,helvetica,sans-serif;font-size: x-small}
.m {font-size: medium}

Here a "error" example:

unknown type
This is a code with an unknown format!


If there exist no Lexer for the given format, PyLucid used the Pygments TextLexer.
So you can make <code=.xy>...</code>, where .xy is any externsion. But for all that it is well displayed through Pygments. Is that cool?


=;-)