Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sean111 authored and shoe committed Feb 27, 2009
1 parent cbc1b3f commit 4210855
Show file tree
Hide file tree
Showing 277 changed files with 505 additions and 40,465 deletions.
18 changes: 10 additions & 8 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
syntax: glob
backend/python/lib
backend/python/include
backend/python/bin
backend/python/devdata
lib
include
bin
frontend/js/dijit
frontend/js/dojo
frontend/js/dojox
backend/python/dist
backend/python/production/libs
backend/python/production/requirements.txt
backend/python/production/bootstrap.py
backend/python/error.txt
backend/python/pip-log.txt
backend/python/devserver.log*
backend/python/setuptools-*
pip-log.txt
devserver.log*
setuptools-*
backend/java/out
*.pyc
backend/python/.Python
.Python
backend/python/BespinServer.egg-info
.DS_Store
*.iws
Expand Down
51 changes: 47 additions & 4 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,54 @@ Live system: https://bespin.mozilla.com/


Thanks for downloading the code to the Bespin project. You can easily get
Bespin running on your local Mac or Linux machine (see note about Windows
below).
Bespin's Python server running on your local Mac or Linux machine (see note
about Windows below).

Getting Started
---------------

*** NOTE FOR LINUX USERS: If you are running on a Linux system, you will
likely need a "python-dev" (on Ubuntu, possibly python-devel elsewhere)
package installed, if you do not already have it.

Run::

python bootstrap.py --no-site-packages

to get the environment set up. This is built around virtualenv. All of the
required packages will automatically be installed. Once this is set up,
you can run::

source bin/activate

to enter the virtualenv. Alternatively, you can just prefix the commands you
run with "bin/". If you wish to restore your command line environment,
you can type "deactivate".

The first time around, you'll need to download Dojo and create the database::

paver dojo create_db

You can start up the development server (runs on localhost:8080) by running::

paver start

You can run the unit tests by running::

py.test bespin

Updating the Required Files
---------------------------

If the "requirements.txt" file changes, you can re-install the required packages
by running::

paver required

You can also force upgrade all of the packages like so::

pip install -U -r requirements.txt

To run Bespin locally, go to backend/python and take a look at the
README.txt file there.

Contributing to Bespin
----------------------
Expand Down
45 changes: 0 additions & 45 deletions backend/python/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,6 @@ This program provides the server side functionality for Bespin. Though there
is nothing Mac or Unix specific to the Bespin server, at the moment it
has only been tested on Unix-like platforms.

Getting Started
---------------

*** NOTE FOR LINUX USERS: If you are running on a Linux system, you will
likely need a "python-dev" (on Ubuntu, possibly python-devel elsewhere)
package installed, if you do not already have it.

Run::

python bootstrap.py

to get the environment set up. This is built around virtualenv. All of the
required packages will automatically be installed. Once this is set up,
you can run::

source bin/activate

to enter the virtualenv. Alternatively, you can just prefix the commands you
run with "bin/". If you wish to restore your command line environment,
you can type "deactivate".

The first time around, you'll need to create the database::

paver create_db

You can start up the development server (runs on localhost:8080) by running::

paver start

You can run the unit tests by running::

py.test bespin

Updating the Required Files
---------------------------

If the "requirements.txt" file changes, you can re-install the required packages
by running::

paver required

You can also force upgrade all of the packages like so::

pip install -U -r requirements.txt

Understanding the Code
----------------------

Expand Down
87 changes: 0 additions & 87 deletions backend/python/pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

from paver.defaults import *

import paver.virtual

execfile(os.path.join('bespin', '__init__.py'))

options(
Expand All @@ -45,17 +43,6 @@
packages=find_packages(),
package_data=find_package_data('bespin', 'bespin',
only_in_packages=False)
),
virtualenv=Bunch(
packages_to_install=['pip'],
paver_command_line="required"
),
server=Bunch(
# set to true to allow connections from other machines
open=False,
port=8080,
try_build=False,
dburl=None
)
)

Expand All @@ -70,80 +57,6 @@ def required():
path("README").unlink()
path("include").rmtree()

@task
def start():
"""Starts the BespinServer on localhost port 8080 for development.
You can change the port and allow remote connections by setting
server.port or server.open on the command line.
paver server.open=1 server.port=8000 start
will allow remote connections (assuming you don't have a firewall
blocking the connection) and start the server on port 8000.
"""
from bespin import config, controllers
from wsgiref.simple_server import make_server

options.order('server')

config.set_profile('dev')

if options.server.try_build:
config.c.static_dir = os.path.abspath("%s/../../build/BespinServer/frontend" % os.getcwd())

if options.server.dburl:
config.c.dburl = options.server.dburl

config.activate_profile()
port = int(options.port)
if options.open in ["True", "true", "yes", "1"]:
listen_on = ""
else:
listen_on = "localhost"
info("Server starting on %s:%s" % (listen_on, port))
make_server(listen_on, port, controllers.make_app()).serve_forever()

@task
def try_build():
"""Starts the server using the compressed JavaScript."""
options.server.try_build=True
start()

@task
def clean_data():
"""Deletes the development data and recreates the database."""
data_path = path("devdata.db")
data_path.unlink()
create_db()

@task
def create_db():
"""Creates the development database"""
from bespin import config, model, db_versions
from migrate.versioning.shell import main

if path("devdata.db").exists():
raise BuildFailure("Development database already exists")
config.set_profile('dev')
config.activate_profile()
dry("Create database tables", model.Base.metadata.create_all, bind=config.c.dbengine)

repository = str(path(db_versions.__file__).dirname())
dburl = config.c.dburl
dry("Turn on migrate versioning", main, ["version_control", dburl, repository])

@task
def upgrade():
"""Upgrade your database."""
from bespin import config, model, db_versions
from migrate.versioning.shell import main
config.set_profile('dev')
config.activate_profile()
repository = str(path(db_versions.__file__).dirname())
dburl = config.c.dburl
dry("Run the database upgrade", main, ["upgrade", dburl, repository])


@task
@needs(['sdist'])
Expand Down
2 changes: 1 addition & 1 deletion backend/python/bootstrap.py → bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ def after_install(options, home_dir):
bin_dir = join(home_dir, 'Scripts')
else:
bin_dir = join(home_dir, 'bin')
subprocess.call([join(bin_dir, 'easy_install'), 'paver==0.8.1'])
subprocess.call([join(bin_dir, 'easy_install'), 'paver>=1.0a2'])
subprocess.call([join(bin_dir, 'easy_install'), 'pip'])
subprocess.call([join(bin_dir, 'paver'),'required'])

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions frontend/js/bespin/bootstrap_dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dojo.require("bespin.client.session");

dojo.require("bespin.editor.actions");
dojo.require("bespin.editor.editor");
dojo.require("bespin.editor.events");
dojo.require("bespin.editor.model");
dojo.require("bespin.editor.toolbar");
dojo.require("bespin.editor.themes");
Expand Down
55 changes: 32 additions & 23 deletions frontend/js/bespin/cmd/commandline.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,25 @@ dojo.declare("bespin.cmd.commandline.Interface", null, {
var commandname = data.shift();

var command;
var argstr = data.join(' ');

if (this.commands[commandname]) {
command = this.commands[commandname];
} else if (this.aliases[commandname]) {
command = this.commands[this.aliases[commandname]];
var alias = this.aliases[commandname].split(' ');
var aliascmd = alias.shift();
if (alias.length > 0) {
argstr = alias.join(' ') + ' ' + argstr;
}
command = this.commands[aliascmd];
} else {
this.showInfo("Sorry, no command '" + commandname + "'. Maybe try to run » help", true);
return;
}

bespin.publish("bespin:cmdline:executed", [{ command: command, args: data.join(' ') }]);
bespin.publish("bespin:cmdline:executed", { command: command, args: argstr });

command.execute(this, this.getArgs(data, command));
command.execute(this, this.getArgs(argstr.split(' '), command));
this.commandLine.value = ''; // clear after the command
},

Expand All @@ -89,7 +95,7 @@ dojo.declare("bespin.cmd.commandline.Interface", null, {
var args = bespin.util.keys.fillArguments(command.withKey);

args.action = "bespin:cmdline:execute;name=" + command.name;
bespin.publish("bespin:editor:bindkey", [args]);
bespin.publish("bespin:editor:bindkey", args);
}

this.commands[command.name] = command;
Expand Down Expand Up @@ -164,17 +170,15 @@ dojo.declare("bespin.cmd.commandline.Interface", null, {
var matches = [];

if (value.length > 0) {
for (command in this.commands) {
for (var command in this.commands) {
if (command.indexOf(value) == 0) {
matches.push(command);
}

if (this.commands[command]['aliases']) {
dojo.forEach(this.commands[command]['aliases'], function(alias) {
if (alias.indexOf(value) == 0) {
matches.push(alias);
}
});
}

for (var alias in this.aliases) {
if (alias.indexOf(value) == 0) {
matches.push(alias);
}
}
}
Expand All @@ -185,22 +189,27 @@ dojo.declare("bespin.cmd.commandline.Interface", null, {
complete: function(value) {
var matches = this.findCompletions(value);
if (matches.length == 1) {
var command = this.commands[matches[0]] || this.commands[this.aliases[matches[0]]];

var commandLineValue = matches[0];

var command = this.commands[matches[0]];

if (this.commandTakesArgs(command)) {
commandLineValue += ' ';
}
this.commandLine.value = commandLineValue;
if (command) {
if (this.commandTakesArgs(command)) {
commandLineValue += ' ';
}

if (command['completeText']) {
this.showInfo(command['completeText']);
}
if (command['completeText']) {
this.showInfo(command['completeText']);
}

if (command['complete']) {
this.showInfo(command.complete(this, value));
if (command['complete']) {
this.showInfo(command.complete(this, value));
}
} else { // an alias
this.showInfo(commandLineValue + " is an alias for: " + this.aliases[commandLineValue]);
commandLineValue += ' ';
}
this.commandLine.value = commandLineValue;
}
},

Expand Down
Loading

0 comments on commit 4210855

Please sign in to comment.