Slide 1

Slide 1 text

danny 2013 1/13 ౦ژRubyձٞ10 Inside Tripclip גࣜձࣾΫϨΠ

Slide 2

Slide 2 text

Tripclipͬͯͳʹʁ

Slide 3

Slide 3 text

http://tripclip.jp • ཱྀߦ΍ࢄาͰࡱͬͨεφοϓࣸਅΛख ܰʹΞϧόϜԽ͢ΔࣗࣾWebαʔϏε • ࣸਅΛϒϥ΢βʹυϥοάΞϯυυϩ οϓ͢Δ͚ͩͰ͖Ε͍ͳΞϧόϜ͕ग़ དྷ্͕Δ • 2012೥10݄ ϦϦʔε

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

ࣗݾ঺հ • ॴଐ • KRAY • Twitter • @f96q • Blog • http://f96q.github.com/

Slide 6

Slide 6 text

KRAYʹ͍ͭͯ

Slide 7

Slide 7 text

ࠓ೔࿩͢ࣄ • σʔλʔߏ଄ • ը૾Ξοϓϩʔυ • ΫϥΠΞϯταΠυϧʔςΟϯά • Coffee Script • ։ൃମ੍ • ·ͱΊ

Slide 8

Slide 8 text

ݴޠ • όοΫΤϯυ • Ruby 1.9.3 • ϑϩϯτΤϯυ • Coffee Script

Slide 9

Slide 9 text

ߏ੒ • Rails 3.2.9 • Mongo DB • Nginx • Unicorn • Amazon EC2 • Amazon S3

Slide 10

Slide 10 text

࣮૷ • ϖʔδભҠ͠ͳ͍ͰɺಈతʹΞϧόϜ Λฤू͢ΔͨΊʹ • ΫϥΠΞϯταΠυMVCʹ͍ۙߏ଄ • όοΫΤϯυͱ͸APIͰ࿈ܞ

Slide 11

Slide 11 text

AlbumView GroupView SectionView TextView PhotoFrameView

Slide 12

Slide 12 text

Coffe Script Class AlbumView GroupView SectionView PhotoFrameView View Class Model Class Event AlbumViewDom GroupViewDom SectionViewDom PhotoFrameView Dom TextView TextViewDom Group Section Text Image Album

Slide 13

Slide 13 text

Coffe Script Class AlbumView GroupView SectionView PhotoFrameView View Class Model Class Event AlbumViewDom GroupViewDom SectionViewDom PhotoFrameView Dom TextView TextViewDom Group Section Text Image Album

Slide 14

Slide 14 text

Coffee Model app = @app class app.Image constructor: (params) -> @[key] = params[key] for key of params update: (params, callback) -> @swap: (params, callback) -> destroy: (callback) ->

Slide 15

Slide 15 text

Coffe Script Class Model Class Ruby Class Model Class /api/album /api/group /api/section /api/image Album Group Section Text Image Album Group Section Image Text /api/text

Slide 16

Slide 16 text

{ "_id" : "50ab69686e9552ef66000001", "title" : null, "user_id" : "50a48a6a6e95521901000001", "groups": [ { "_id" : "50ab69686e9552ef66000002", "layout" : "default", "sections" : [ { "_id" : "50ab69686e9552ef66000003", "images" : [ { "_id" : "50d2581e6e95529e3500000a", "caption" : "", "height" : 1936, "width" : 2592, "top" : 0, "left" : 0, "longitude" : 139.57016666666667, "latitude" : 35.696333333333335 } ], "texts": [ { "_id" : "50ab69686e9552ef66000004", "body" : "" }, { "_id" : "50ab69686e9552ef66000005", "body" : "" } ] } ] } ] } BSON Album Group Section Text Image

Slide 17

Slide 17 text

Ξοϓϩʔυ • file-uploader • https://github.com/valums/file-uploader • ෳ਺ຕը૾Ξοϓϩʔυ࣌ʹ͕ۭؒͷ ৔߹ʹͦ͜ʹ഑ஔ͢ΔͷΛ࣮ݱ͢Δͷ ͕೉͔ͬͨ͠ɻ • jQuery File Upload • https://github.com/blueimp/jQuery-File- Upload

Slide 18

Slide 18 text

Ξοϓϩʔυ • Amazon S3ʹΞοϓϩʔυ • HttpImageFilterModule • NginxͷϞδϡʔϧ • ը૾ͷαΠζม׵ • RailsଆͰ࣮૷͠ͳͯ͘ࡁΉ

Slide 19

Slide 19 text

ϧʔςΟϯά $ -> app.album = new app.Album() if $('#my-album').size() > 0 album_url = $('#album-status').data('path') $('#album-title').editInPlace url: album_url method: 'PUT' params: 'type=inplace_title' default_text: app.I18n.album.placeholder show_buttons: true save_button: app.inplace_save_button cancel_button: app.inplace_cancel_button $ -> uploader = $('#uploader') if uploader[0] app.create_uploader() albums.js.coffee images.js.coffee • Asset PipelineͰશ෦ͷjsɺcss͕ಡΈࠐ·ΕΔ • ϑΝΠϧ͝ͱʹwindow.onloadͯ͠͠·͏ͱ࣮ߦ ॱং͕௥͍ʹ͍͘

Slide 20

Slide 20 text

Data Attributes app/view/application.html.erb

Slide 21

Slide 21 text

routes app = @app route = (params) -> if $('body').data('controller') is params.controller and $('body').data('action') is params.action then true else false $ -> app.Options.load() if route(controller: 'albums', action: 'show') new app.OthersAlbumView else if route(controller: 'albums', action: 'edit') new app.AlbumView new app.SiteView if route(controller: 'site', action: 'index') new app.ContactView

Slide 22

Slide 22 text

Scope (function() { var Image; Image = (function() { function Image() {} return Image; })(); }).call(this); class Image Coffee Script JavaScript

Slide 23

Slide 23 text

application.js this.app = {};

Slide 24

Slide 24 text

Scope (function() { this.app.Image = (function() { function Image() {} return Image; })(); }).call(this); Coffee Script JavaScript class @app.Image

Slide 25

Slide 25 text

։ൃମ੍ • ࠷ॳ • GithubΫϩʔϯ(Gitorious) • ਵ࣌masterʹίϛοτ • ໰୊఺ • ιʔείʔυ͕ܧ͗઀͗ʹͳΔ • ։ൃऀಉ࢜ͷٞ࿦͠ʹ͍͘

Slide 26

Slide 26 text

ίʔυϨϏϡʔ • GitHub • ػೳΛ࣮૷͢Δͷʹϒϥϯν੾ͬͯɺ ࣮૷͠ऴΘͬͨΒpull request • ίϝϯτͰ࣮૷ͨ͠ਓमਖ਼ • ϨϏϡʔͨ͠ਓ͕ίϛοτΛࡌ͚ͬΔ ৔߹΋͋Δ • ͦͷػೳΛ࣮૷ͨ͠Ҏ֎ͷਓ͕merge

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

ϛαϫ

Slide 29

Slide 29 text

·ͱΊ • ಈతʹΞϧόϜฤू͢ΔͨΊʹ • ΫϥΠΞϯτଆʹ΋MVCΞʔΩςΫ νϟʹ͍ۙߏ଄ʹ • Ұ؏ੑͷ͋ΔΫϥεͷߏ଄ • ιʔείʔυ͕ಡΈ΍͘͢ͳͬͨ • ֦ு͠΍͘͢ͳͬͨ