site banner

powered by PyLucid v0.8.0
render time: 47.1 ms - overall: 79.0 ms - queries: 28

SourceCode

last modified: 2007-10-29 05:44:26
permalink to this page

SourceCode Plugin

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

Example Tag:

{% 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 TinyTextileExample

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
/* ___________________________________________________________________________
 *  Some needed stuff round the SHA-JS-Login
 */

check_ok = false;
debug_msg = false;

// length of a SHA1 hexdigest string:
HASH_LEN = 40;


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 functions:
 */

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

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

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

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 = document.getElementById(object_id).value;
        debug("in_pass:" + in_pass);
        if (in_pass.length<8) {
            alert("Password min len 8! - current len:" + in_pass.length);
            return false;
        }

		if (check_ascii_only(in_pass) == false) {
			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;
    }
}

function set_value(object_id, value, color_name) {
    try {
        // set the value and change the css color.
        document.getElementById(object_id).value = value;
        change_color(object_id, color_name);
    } catch (e) {
        alert("set_value("+object_id+", "+value+", "+color_name+") error:" + e);
    }
}

/* ___________________________________________________________________________
 *  debugging:
 */

function init_debug() {
    try {
        if (debug_msg != true) { return; }
        property = "dependent=yes,resizable=yes,width=350,height=400,top=1,left=" + window.outerWidth;
        debug_window = window.open("about:blank", "Debug", property);
        debug_window.focus();
        debug_win = debug_window.document;
        debug_win.writeln("<style>* { font-size: 0.85em; }</style>");
        debug_win.writeln("<h1>JS Debug:</h1>");
        debug_win.writeln("---[DEBUG START]---");
        debug_win.writeln("cookie:" + document.cookie +"<br />");

        document.body.onunload = "debug_window.close();";
    } catch (e) {
        alert("init_debug() error:" + e);
    }
}
function debug(msg) {
    try {
        if (debug_msg != true) { return; }
        debug_win.writeln(msg + "<br />");
    } catch (e) {
        alert("debug() error:" + e);
    }
}
function debug_confirm() {
    try {
       if (debug_msg != true) { return; }
       debug_window.focus();
       debug_win.writeln("---[DEBUG END]---");
       alert('OK for submit.');
       debug_window.close();
    } 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?


=;-)