~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/apps/console/__init__.py

  • Committer: mattgiuca
  • Date: 2008-01-29 23:52:19 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:329
Converted Console from an "app" into a "plugin". It can now be plugged in to
any app.
Added "plugins" directory in www. Added "console" plugin. This contains all of
the functionality of what was previously the console app, but modularized so
it can be imported by another app.

apps/console: Removed most of the logic (moved to plugins/console). Replaced
with a simple import of the console plugin. Should behave exactly the same.
apps/tutorial: As proof of concept, imported the console plugin. It now
appears at the bottom of the page (yet to make it have "pop up" behaviour).

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
# App: console
19
19
# Author: Matt Giuca
20
 
# Date: 12/1/2008
 
20
# Date: 30/1/2008
21
21
 
22
22
# Console application.
23
 
# Not yet implemented.
 
23
# Presents a Python console as a complete app. (This simply imports the
 
24
# Console plugin - see plugins/console).
24
25
 
25
26
from common import util
 
27
import plugins.console
26
28
 
27
29
def handle(req):
28
30
    """Handler for the Console application."""
31
33
    req.content_type = "text/html"
32
34
    req.write_html_head_foot = True     # Have dispatch print head and foot
33
35
 
34
 
    req.scripts = [
35
 
        "media/common/json2.js",
36
 
        "media/common/md5.js",
37
 
        "media/common/util.js",
38
 
        "media/console/console.js",
39
 
    ]
40
 
    req.styles = [
41
 
        "media/console/console.css",
42
 
    ]
 
36
    # Let the plugin mandate the scripts and styles to use
 
37
    req.scripts = []
 
38
    req.styles = []
 
39
    plugins.console.insert_scripts_styles(req.scripts, req.styles)
43
40
 
44
 
    req.write("""<div id="console_body">
45
 
  <div id="console_output">
46
 
  </div>
47
 
  <div id="console_input">
48
 
   <div id="console_inputArea">
49
 
   </div>
50
 
   <label id="console_prompt">&gt;&gt;&gt;&nbsp;</label>
51
 
   <input id="console_inputText"
52
 
     type="text" size="80" onkeypress="catch_input(event.keyCode)" />
53
 
  </div>
54
 
</div>
55
 
""")
 
41
    # Let the plugin write the HTML body
 
42
    plugins.console.present(req)