| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
""" |
| 6 |
|
| 7 |
FCKeditor - The text editor for Internet - http://www.fckeditor.net |
| 8 |
|
| 9 |
Copyright (C) 2003-2009 Frederico Caldeira Knabben |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
== BEGIN LICENSE == |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
Licensed under the terms of any of the following licenses at your |
| 18 |
|
| 19 |
choice: |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
- GNU General Public License Version 2 or later (the "GPL") |
| 24 |
|
| 25 |
http://www.gnu.org/licenses/gpl.html |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
- GNU Lesser General Public License Version 2.1 or later (the "LGPL") |
| 30 |
|
| 31 |
http://www.gnu.org/licenses/lgpl.html |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
- Mozilla Public License Version 1.1 or later (the "MPL") |
| 36 |
|
| 37 |
http://www.mozilla.org/MPL/MPL-1.1.html |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
== END LICENSE == |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
Sample page. |
| 46 |
|
| 47 |
""" |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
import cgi |
| 52 |
|
| 53 |
import os |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
# Ensure that the fckeditor.py is included in your classpath |
| 58 |
|
| 59 |
import fckeditor |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
# Tell the browser to render html |
| 64 |
|
| 65 |
print "Content-Type: text/html" |
| 66 |
|
| 67 |
print "" |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
# Document header |
| 72 |
|
| 73 |
print """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 74 |
|
| 75 |
<html> |
| 76 |
|
| 77 |
<head> |
| 78 |
|
| 79 |
<title>FCKeditor - Sample</title> |
| 80 |
|
| 81 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 82 |
|
| 83 |
<meta name="robots" content="noindex, nofollow"> |
| 84 |
|
| 85 |
<link href="../sample.css" rel="stylesheet" type="text/css" /> |
| 86 |
|
| 87 |
</head> |
| 88 |
|
| 89 |
<body> |
| 90 |
|
| 91 |
<h1>FCKeditor - Python - Sample 1</h1> |
| 92 |
|
| 93 |
This sample displays a normal HTML form with an FCKeditor with full features |
| 94 |
|
| 95 |
enabled. |
| 96 |
|
| 97 |
<hr> |
| 98 |
|
| 99 |
<form action="sampleposteddata.py" method="post" target="_blank"> |
| 100 |
|
| 101 |
""" |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
# This is the real work |
| 106 |
|
| 107 |
try: |
| 108 |
|
| 109 |
sBasePath = os.environ.get("SCRIPT_NAME") |
| 110 |
|
| 111 |
sBasePath = sBasePath[0:sBasePath.find("_samples")] |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
oFCKeditor = fckeditor.FCKeditor('FCKeditor1') |
| 116 |
|
| 117 |
oFCKeditor.BasePath = sBasePath |
| 118 |
|
| 119 |
oFCKeditor.Value = """<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>""" |
| 120 |
|
| 121 |
print oFCKeditor.Create() |
| 122 |
|
| 123 |
except Exception, e: |
| 124 |
|
| 125 |
print e |
| 126 |
|
| 127 |
print """ |
| 128 |
|
| 129 |
<br> |
| 130 |
|
| 131 |
<input type="submit" value="Submit"> |
| 132 |
|
| 133 |
</form> |
| 134 |
|
| 135 |
""" |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
# For testing your environments |
| 140 |
|
| 141 |
print "<hr>" |
| 142 |
|
| 143 |
for key in os.environ.keys(): |
| 144 |
|
| 145 |
print "%s: %s<br>" % (key, os.environ.get(key, "")) |
| 146 |
|
| 147 |
print "<hr>" |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
# Document footer |
| 152 |
|
| 153 |
print """ |
| 154 |
|
| 155 |
</body> |
| 156 |
|
| 157 |
</html> |
| 158 |
|
| 159 |
""" |
| 160 |
|
| 161 |
|