Update Readme. Make static.py serve on port 8888 like static.js does.

This commit is contained in:
Julian Viereck 2011-05-21 12:07:35 +02:00 • committed by Fabian Jakobs
commit bc93a71771
2 changed files with 53 additions and 23 deletions

View file

@ -16,6 +16,10 @@ Features
* Highlight matching parentheses * Highlight matching parentheses
* Toggle between soft tabs and real tabs * Toggle between soft tabs and real tabs
* Displays hidden characters * Displays hidden characters
* Drap and drop text using the mouse
* Line wrapping
* Unstructured / user code folding
* Live syntax checker (currently JavaScript/CoffeeScript)
Take Ace for a spin! Take Ace for a spin!
-------------------- --------------------
@ -35,6 +39,7 @@ Getting the code
Ace is a community project. We actively encourage and support contributions. The Ace source code is hosted on GitHub. It is released under the Mozilla tri-license (MPL/GPL/LGPL), the same license used by Firefox. This license is friendly to all kinds of projects, whether open source or not. Take charge of your editor and add your favorite language highlighting and keybindings! Ace is a community project. We actively encourage and support contributions. The Ace source code is hosted on GitHub. It is released under the Mozilla tri-license (MPL/GPL/LGPL), the same license used by Firefox. This license is friendly to all kinds of projects, whether open source or not. Take charge of your editor and add your favorite language highlighting and keybindings!
git clone git://github.com/ajaxorg/ace.git git clone git://github.com/ajaxorg/ace.git
cd ace
git submodule update --init --recursive git submodule update --init --recursive
Embedding Ace Embedding Ace
@ -54,30 +59,39 @@ The easiest version is simply:
With "editor" being the id of the DOM element, which should be converted to an editor. Note that this element must be explicitly sized and positioned `absolute` or `relative` for Ace to work. e.g. With "editor" being the id of the DOM element, which should be converted to an editor. Note that this element must be explicitly sized and positioned `absolute` or `relative` for Ace to work. e.g.
#editor { #editor {
position: absolute; position: absolute;
width: 500px; width: 500px;
height: 400px; height: 400px;
} }
To change the theme simply include the Theme's JavaScript file To change the theme simply include the Theme's JavaScript file
<script src="src/theme-twilight.js" type="text/javascript" charset="utf-8"></script> <script src="src/theme-twilight.js" type="text/javascript" charset="utf-8"></script>
and configure the editor to use the theme: and configure the editor to use the theme:
editor.setTheme("ace/theme/twilight"); editor.setTheme("ace/theme/twilight");
By default the editor only supports plain text mode; many other languages are available as separate modules. After including the mode's JavaScript file: By default the editor only supports plain text mode; many other languages are available as separate modules. After including the mode's JavaScript file:
<script src="src/mode-javascript.js" type="text/javascript" charset="utf-8"></script> <script src="src/mode-javascript.js" type="text/javascript" charset="utf-8"></script>
Then the mode can be used like this: Then the mode can be used like this:
var JavaScriptMode = require("ace/mode/javascript").Mode; var JavaScriptMode = require("ace/mode/javascript").Mode;
editor.getSession().setMode(new JavaScriptMode()); editor.getSession().setMode(new JavaScriptMode());
Documentation
-------------
You find a lot more sample code in the [demo app](https://github.com/ajaxorg/ace/blob/master/demo/demo.js).
There is also some documentation on the [wiki page](https://github.com/ajaxorg/ace/wiki).
If you still need help, feel free to drop a mail on the [ace mailing list](http://groups.google.com/group/ace-discuss).
Running Ace Running Ace
----------- -----------
@ -85,7 +99,11 @@ After the checkout Ace works out of the box. No build step is required. Open 'ed
./static.py ./static.py
The editor can then be opened at http://localhost:9999/editor.html. Or using Node.JS
./static.js
The editor can then be opened at http://localhost:8888/index.html.
Package Ace Package Ace
----------- -----------
@ -96,10 +114,14 @@ To package Ace we use the dryice build tool developed by the Mozilla Skywriter t
Afterwards Ace can be built by calling Afterwards Ace can be built by calling
./Makefile.dryice.js ./Makefile.dryice.js normal
The packaged Ace will be put in the 'build' folder. The packaged Ace will be put in the 'build' folder.
To build the bookmarklet version execute
./Makefile.dryice.js bm
Running the Unit Tests Running the Unit Tests
---------------------- ----------------------
@ -111,6 +133,14 @@ To run the tests call:
node lib/ace/test/all.js node lib/ace/test/all.js
You can also run the tests in your browser by serving:
http://localhost:8888/lib/ace/test/tests.html
This makes debugging failing tests way more easier.
_Note_: Currently (2011-05-21) the tests seem to run on Chrome only.
Contributing Contributing
------------ ------------

View file

@ -18,8 +18,8 @@ Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to: License along with this library; if not, write to:
The Free Software Foundation, Inc., The Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
Luke Arno can be found at http://lukearno.com/ Luke Arno can be found at http://lukearno.com/
@ -49,14 +49,14 @@ class MagicError(Exception): pass
class StatusApp: class StatusApp:
"""Used by WSGI apps to return some HTTP status.""" """Used by WSGI apps to return some HTTP status."""
def __init__(self, status, message=None): def __init__(self, status, message=None):
self.status = status self.status = status
if message is None: if message is None:
self.message = status self.message = status
else: else:
self.message = message self.message = message
def __call__(self, environ, start_response, headers=[]): def __call__(self, environ, start_response, headers=[]):
if self.message: if self.message:
Headers(headers).add_header('Content-type', 'text/plain') Headers(headers).add_header('Content-type', 'text/plain')
@ -69,9 +69,9 @@ class StatusApp:
class Cling(object): class Cling(object):
"""A stupidly simple way to serve static content via WSGI. """A stupidly simple way to serve static content via WSGI.
Serve the file of the same path as PATH_INFO in self.datadir. Serve the file of the same path as PATH_INFO in self.datadir.
Look up the Content-type in self.content_types by extension Look up the Content-type in self.content_types by extension
or use 'text/plain' if the extension is not found. or use 'text/plain' if the extension is not found.
@ -173,17 +173,17 @@ def iter_and_close(file_like, block_size):
else: raise StopIteration else: raise StopIteration
except StopIteration, si: except StopIteration, si:
file_like.close() file_like.close()
return return
def cling_wrap(package_name, dir_name, **kw): def cling_wrap(package_name, dir_name, **kw):
"""Return a Cling that serves from the given package and dir_name. """Return a Cling that serves from the given package and dir_name.
This uses pkg_resources.resource_filename which is not the This uses pkg_resources.resource_filename which is not the
recommended way, since it extracts the files. recommended way, since it extracts the files.
I think this works fine unless you have some _very_ serious I think this works fine unless you have some _very_ serious
requirements for static content, in which case you probably requirements for static content, in which case you probably
shouldn't be serving it through a WSGI app, IMHO. YMMV. shouldn't be serving it through a WSGI app, IMHO. YMMV.
""" """
resource = Requirement.parse(package_name) resource = Requirement.parse(package_name)
@ -191,7 +191,7 @@ def cling_wrap(package_name, dir_name, **kw):
def command(): def command():
parser = OptionParser(usage="%prog DIR [HOST][:][PORT]", parser = OptionParser(usage="%prog DIR [HOST][:][PORT]",
version="static 0.3.6") version="static 0.3.6")
options, args = parser.parse_args() options, args = parser.parse_args()
if len(args) in (1, 2): if len(args) in (1, 2):
@ -209,7 +209,7 @@ def command():
if not host: if not host:
host = '0.0.0.0' host = '0.0.0.0'
if not port: if not port:
port = 9999 port = 8888
try: try:
port = int(port) port = int(port)
except: except:
@ -230,8 +230,8 @@ def test():
from wsgiref.validate import validator from wsgiref.validate import validator
app = Cling(getcwd()) app = Cling(getcwd())
try: try:
print "Serving " + getcwd() + " to http://localhost:9999" print "Serving " + getcwd() + " to http://localhost:8888"
make_server('0.0.0.0', 9999, validator(app)).serve_forever() make_server('0.0.0.0', 8888, validator(app)).serve_forever()
except KeyboardInterrupt, ki: except KeyboardInterrupt, ki:
print "" print ""
print "Ciao, baby!" print "Ciao, baby!"