mozilla / thimble.mozilla.org
- вторник, 20 сентября 2016 г. в 03:15:37
JavaScript
Online code editor geared to people teaching and learning HTML, CSS, and JavaScript.
Thimble is Mozilla's online code editor that makes it easy to create and publish your own web pages while learning HTML, CSS & JavaScript. You can try it online by visiting https://thimble.mozilla.org (or https://bramble.mofostaging.net for our staging server).
You can read more about some of Thimble's main features in the wiki, or watch a demo video.
Thimble uses a modified version of the amazing Brackets code editor updated to run within web browsers. You can read more about how it works in this blog post.
Thimble requires a modern web browser, and we recommend using Mozilla Firefox or Google Chrome.
Thimble is non-trivial to run locally, due to its dependence on a number of other services. In order to run Thimble, the following things are required. The following is an abbreviated guide to getting it all set up. Please see each server's README for more details.
You'll need
Please note: On Windows, use copy instead of cp
Bramble
git submodule update --init to install submodulesnpm install to install dependenciesnpm run build to create /dist extensions and third-party libsnpm start to get a static server running on http://localhost:8000/src. You can try the demo version at http://localhost:8000/src/hosted.htmlThimble
cp env.dist .env to create an environment filenpm install to install dependenciesnpm run localize to generate the locale filesnpm start to start the serverid.webmaker.org
cp sample.env .env to create an environment filenpm install to install dependenciesnpm start to start the serverlogin.webmaker.org
npm install to install dependenciescp env.sample .env to create an environment filenpm start the serverPostgreSQL
brew install postgresql to install PostgreSQL once Homebrew is installedinitdb -D /usr/local/var/postgres to initialize PostreSQL
rm -rf /usr/local/var/postgres to remove itpostgres -D /usr/local/var/postgres to start the PostgreSQL servercreatedb publish to create the Publish databasepublish.webmaker.org
npm install to install dependenciesnpm run envnpm install knex -g to install knexnpm run knex to seed the publish database created earliernpm start to run the serverTo publish locally, you'll need to do the following...
1. Teach the ID server about the Publish server
createdb webmaker_oauth_test to create a test databaseIn your id.webmaker.org folder
node scripts/create-tables.jsEdit scripts/test-data.sql and replace it's contents with:
INSERT INTO clients VALUES
( 'test',
'test',
'["password", "authorization_code"]'::jsonb,
'["code", "token"]'::jsonb,
'http://localhost:3500/callback' )Run node scripts/test-data.js
INSERT 0 1 message if successful2. Set up the local data folder
Instead of publishing to Amazon AWS, we'll be publishing to a local folder. Perform the following steps to set this up.
npm install -g http-server && mkdir -p /tmp/mox/test && cd /tmp/mox/test && http-server -p 8001cd /tmp/mox/test && http-server -p 8001 to start the server.env filePUBLIC_PROJECT_ENDPOINT="localhost:8001"` is set as shown here3. Sign In
To publish locally, you'll need an account.
Join Webmaker and complete the process, you can use a fake emailSet permanent password instead
This is the list of commands to get each part up and running.
npm startnpm startpostgres -D /usr/local/var/postgresnpm startnpm startnpm startcd /tmp/mox/test && http-server -p 8001We handle JS, HTML and CSS linting through grunt, which is very simple to set up if you don't have it installed already:
npm install -g grunt-cli
After this, simpy run grunt before commiting code and you should
be good to go.
Run grunt requirejs:dist to regenerate the front-end dist/ folder if you so desire (it's
only necessary in production). See Gruntfile.js for details.
Please refer to the Wiki for information on the localization procedures used in Thimble.
Our localization community is awesome! They work very hard to translate Thimble so that we can expand our global reach and engage even more users in other languages. We can't thank them enough!
To invalidate the production CloudFront distribution, make sure you have correct credentials set up in your env file. Then run node invalidate.js. Alternatively, if you have access to the heroku deployments, run the invalidation as a one-off dyno with heroku run npm run invalidate
Thimble uses the throng module to leverage Node's Cluster API for concurrency. To specify the number of server processes to start set WEB_CONCURRENCY to a positive integer value.