sample01.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/usr/bin/env python
  2. """
  3. FCKeditor - The text editor for Internet - http://www.fckeditor.net
  4. Copyright (C) 2003-2009 Frederico Caldeira Knabben
  5. == BEGIN LICENSE ==
  6. Licensed under the terms of any of the following licenses at your
  7. choice:
  8. - GNU General Public License Version 2 or later (the "GPL")
  9. http://www.gnu.org/licenses/gpl.html
  10. - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  11. http://www.gnu.org/licenses/lgpl.html
  12. - Mozilla Public License Version 1.1 or later (the "MPL")
  13. http://www.mozilla.org/MPL/MPL-1.1.html
  14. == END LICENSE ==
  15. Sample page.
  16. """
  17. import cgi
  18. import os
  19. # Ensure that the fckeditor.py is included in your classpath
  20. import fckeditor
  21. # Tell the browser to render html
  22. print "Content-Type: text/html"
  23. print ""
  24. # Document header
  25. print """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  26. <html>
  27. <head>
  28. <title>FCKeditor - Sample</title>
  29. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  30. <meta name="robots" content="noindex, nofollow">
  31. <link href="../sample.css" rel="stylesheet" type="text/css" />
  32. </head>
  33. <body>
  34. <h1>FCKeditor - Python - Sample 1</h1>
  35. This sample displays a normal HTML form with an FCKeditor with full features
  36. enabled.
  37. <hr>
  38. <form action="sampleposteddata.py" method="post" target="_blank">
  39. """
  40. # This is the real work
  41. try:
  42. sBasePath = os.environ.get("SCRIPT_NAME")
  43. sBasePath = sBasePath[0:sBasePath.find("_samples")]
  44. oFCKeditor = fckeditor.FCKeditor('FCKeditor1')
  45. oFCKeditor.BasePath = sBasePath
  46. oFCKeditor.Value = """<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>"""
  47. print oFCKeditor.Create()
  48. except Exception, e:
  49. print e
  50. print """
  51. <br>
  52. <input type="submit" value="Submit">
  53. </form>
  54. """
  55. # For testing your environments
  56. print "<hr>"
  57. for key in os.environ.keys():
  58. print "%s: %s<br>" % (key, os.environ.get(key, ""))
  59. print "<hr>"
  60. # Document footer
  61. print """
  62. </body>
  63. </html>
  64. """