Crash Course to CompoundJS
もともとはRailwayJSという名前だったみたいだ。
npm を使ってCompoundJSをダウンロード&インストール
# npm install compound -g
アプリ作成
# compound init compound-blog
create compound-blog
create compound-blog/app/
create compound-blog/app/assets/
create compound-blog/app/assets/coffeescripts/
create compound-blog/app/assets/stylesheets/
create compound-blog/app/models/
create compound-blog/app/controllers/
create compound-blog/app/observers/
create compound-blog/app/helpers/
create compound-blog/app/views/
create compound-blog/app/views/layouts/
create compound-blog/db/
create compound-blog/db/seeds/
create compound-blog/db/seeds/development/
:
:
依存モジュールのインストール
# cd compound-blog; npm install
npm http GET https://registry.npmjs.org/ejs-ext
npm http GET https://registry.npmjs.org/co-assets-compiler
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/nodeunit
npm http GET https://registry.npmjs.org/sinon
npm http GET https://registry.npmjs.org/supertest
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/mocha
npm http GET https://registry.npmjs.org/semicov
npm http GET https://registry.npmjs.org/stylus
:
:
Generatorを使ってappの機能を作成
# compound generate crud post title content
exists app/
exists app/controllers/
exists app/helpers/
exists app/views/
create app/views/posts/
exists app/views/layouts
create test/
create test/controllers/
create app/controllers/posts_controller.js
exists app/
exists app/models/
create app/models/post.js
patch db/schema.js
create app/views/layouts/posts_layout.ejs
create app/views/posts/_form.ejs
create app/views/posts/show.ejs
create app/views/posts/new.ejs
create app/views/posts/edit.ejs
create app/views/posts/index.ejs
create app/helpers/posts.js
create test/controllers/posts_controller.test.js
create test/init.js
patch config/routes.js
起動!
# compound server 3000
Compound server listening on 0.0.0.0:3000 within development environment
なんか出た。ルーティングをしろとあるので、してみる。
config/routes.js
exports.routes = function (map) {
map.resources('posts');
map.get('/', 'posts#index');
// Generic routes. Add all your routes below this line
// feel free to remove generic routes
map.all(':controller/:action');
map.all(':controller/:action/:id');
};
しかし何も変わらない。なぜに。仕方ないので直接 posts#index にアクセス。
さすがにここから先は無理っぽい。
0 件のコメント:
コメントを投稿