transponder 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c4b109329b9539fda9e7827ec7474cbfe815c68
4
- data.tar.gz: 2090f8944db3ff86c63e4c97f626a32f6b262b4d
3
+ metadata.gz: 6feff04c3e1786bc152beb0e5750d59c2979bf45
4
+ data.tar.gz: 992b7431c2c704371e50ff763047354b12293a97
5
5
  SHA512:
6
- metadata.gz: 50a1eaad9dc8e5d3a92bacb0bdd121422bc7cb2ed1a358a1fdbc9a06320afc11eff27a01f001d0e1ec2509b457c030f3810848946cf11608c917fe8ffc36e748
7
- data.tar.gz: da4873b9083aeb6c1a1a33612bb24df26a5542209944b9ac9abfbae969387973d10669e74defc3647c41020deaade69bf5b42fb43dac6782a153f328688e4406
6
+ metadata.gz: dd203125d52101183f4fcf6edac72fe46c40e64510be5a1fddbdbf2d9e8dba2e601282a305a2378bde6cbed06954a089197eb110beb55d96e120bbc76033504f
7
+ data.tar.gz: 3ab315529d479230a206e4c9bce68b548fe059e5da9340f6b355e8b8edead1a8169188732518fb964b79a2cfe13496f7638a3dfba5a9c25626243c7d1aebf5fd
data/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # Transponder
2
- [![Build Status](https://travis-ci.org/artellectual/transponder.png?branch=master)](https://travis-ci.org/artellectual/transponder) - Master (current release)
2
+ [![Build Status](https://travis-ci.org/xpdr/transponder.png?branch=master)](https://travis-ci.org/artellectual/transponder) - Master (current release)
3
3
 
4
- [![Build Status](https://travis-ci.org/artellectual/transponder.png?branch=develop)](https://travis-ci.org/artellectual/transponder) - Develop (upcoming release)
4
+ [![Build Status](https://travis-ci.org/xpdr/transponder.png?branch=develop)](https://travis-ci.org/artellectual/transponder) - Develop (upcoming release)
5
5
 
6
- Transponder is a opinionated javascript library for assisting in working with front end heavy rails app.
6
+ ![Transponder Banner](http://transponder.s3-ap-northeast-1.amazonaws.com/transponder-banner.png)
7
7
 
8
- Transponder uncompressed is about 8kb uncompressed / 2kb minified & compressed (gzip)
8
+ Transponder is a opinionated library for assisting in working with front end heavy rails app.
9
+
10
+ 8kb uncompressed / 2kb minified & compressed (gzip) (client side library)
9
11
 
10
12
  ## Installation
11
13
 
@@ -21,65 +23,95 @@ Or install it yourself as:
21
23
 
22
24
  $ gem install transponder
23
25
 
24
- ## Usage
25
- There are 3 types of transponder module, minimal, basic, full by using the ```-t``` flag you can specify which type you want to use. If you don't specify a ```-t``` flag it will generate a basic module.
26
26
 
27
- ### Minimal
28
- Minimal transponder modules are good for generating modules that will contain only services that will be used by other modules. Generally recommended to use in combination with the ```--shared``` flag
27
+ ## Generate a basic Module
28
+
29
+ A transponder module provides some basic structure for your javascript code
30
+ ```
31
+ rails g transponder:install application
32
+ ```
33
+ This will generate a transponder 'module' in your ```app/assets/javascripts``` folder by the name of 'application', you can change the ```application``` to something else, but we recommend sticking with defaults until you understand more about transponder.
34
+
35
+ ## Generate a Presenter
36
+
37
+ Presenters is perhaps one of the most important thing about Transponder, it allows you to use your server side templates in your client side code, cleanly and allows better reuseability of code.
38
+
39
+ ```
40
+ rails g transponder:presenter contacts
41
+ ```
42
+
43
+ Running this command will generate a presenter in your Transponder module ```application/presenters``` with the name ```contacts_presenter.coffee```
44
+
29
45
 
30
- $ rails g transponder:install utilities -t minimal --shared
46
+ ## How is this better than Rails UJS?
31
47
 
32
- ### Basic
33
- Basic transponder modules come with 3 basic things, helpers, services, and presenters. If you want to work with rails controller you will need to use the basic module type.
48
+ Typically with Rails UJS you would create a view with something like this
34
49
 
35
- $ rails g transponder:install application
50
+ Lets say you have a basic contacts_controller.rb
36
51
 
37
- ### Full
38
- Full transponder modules come with transponder's primitives and placeholders for a backbone app, it will setup the integration for a backbone app into your transponder module.
52
+ ```ruby
53
+ class ContactsController < ApplicationController
54
+ respond_to :json, :html, :js
39
55
 
40
- $ rails g transponder:install application -t full
56
+ def index
57
+ @contacts = Contact.all
58
+ respond_with @contacts
59
+ end
60
+ end
61
+ ```
41
62
 
42
- ## Primitives
63
+ In your ```index.js.erb``` you would then have something like this
43
64
 
44
- ### Presenters
45
- Presenter's jobs are to take the response from the server usually html fragment that is rendered by rails and output it to the screen. The reason why we have presenters is so that we can do things to the content before outputting it.
65
+ ```js
66
+ $('#contacts').html("<%= j render @contacts %>");
67
+ ```
46
68
 
47
- Presenters usually map to your controller action in rails. By default it supports the 7 basic restful actions
69
+ This Javascript code is evaled in the browser and content of the node with the id ```#contacts``` gets replaced with server side template that came from ```<%= j render @contacts %>``` This is fine however it has a few problems. First of all if you use coffeescript it has to be compiled in real time as its responding which adds to your response time. Secondly if you want to do more complex things in your response things can get very messy. Code reuse isn't that great either.
48
70
 
49
- + index
50
- + new
51
- + edit
52
- + show
53
- + create
54
- + update
55
- + destroy
71
+ With Transponder you have a consistent way of working with your server side template. Lets take a look at the difference
56
72
 
57
- However you can override this and add your own custom presenter actions if you want. Its not necessary that the presenter action maps to your rails controller action.
73
+ In your ```index.js.erb``` transponder version would look something like this.
58
74
 
59
- #### Presenter in Action
75
+ ```js
76
+ ["#contacts", "<%= xms_event %>", "<%= j render @contacts %>"]
77
+ ```
60
78
 
79
+ Your server side response code using transponder will mostly likely look something like this. There is consistency to it. The first element is the DOM node you want to manipulate, the second element is what will allow the client side Transponder code to know which Presenter is responsible for this response and lastly we have the server side generated content.
61
80
 
62
- ### Services
63
- Services are things that apply to alot of items on the page. You could think of these parts of the page as 'widget' and they all have a certain kind of behavior. The behavior of these widgets can be defined by services. Each widget can have the behavior of multiple services.
81
+ ### So what happens once this response gets to the client
64
82
 
65
- Some example of services
83
+ Well in our presenter we would do something like this
66
84
 
67
- + File uploader
68
- + Poller
69
- + Push notification subscriber
70
- + Syntax Highlighter
71
- + Search Bar
85
+ ```coffee
86
+ class Application.Presenters.ContactsPresenter extends Transponder.Presenter
87
+ presenterName: 'contacts'
88
+ module: 'application'
72
89
 
73
- Services are very modular and they can be applied to multiple widgets in a page without conflicting with each other and without rebinding widgets that already have these behaviors.
90
+ index: ->
91
+ $(@element).html(@response)
92
+ # ... do more stuff ...
93
+ ```
74
94
 
95
+ The first 3 lines of code are generated by the presenter generator you were just using before the only line of code you should pay attention to here is the last 2. Basically the ```@element``` is the dom element you specified in ```index.js.erb``` and the ```@response``` is the content that was rendered by the server.
96
+
97
+ In the presenter you can do pretty much anything you want to your response before it gets output to the DOM. This gives a nice structure and consistency to the whole pattern. It allows you to mix server side templates with full client side programmability.
98
+
99
+ Testing is also much easier as now you've shifted the responsibility of the client side behavior to the client. We have more documentation coming on how to test your presenters.
100
+
101
+ ## Example App
102
+
103
+ Here is a link to a more typical example with a controller / presenter that is more fleshed out. [Presenters: Typical Example](https://github.com/xpdr/transponder/wiki/Presenters:-Typical-Example). The code in the link is the controller / presenter code for this app here
104
+ + [kontax on heroku](http://kontax.herokuapp.com)
105
+ + [kontax on github](http://github.com/xpdr/kontax)
106
+
107
+ Kontax is an example app for showcasing what Transponder is capable of doing. The larger and more complex an app becomes the more transponder shines. Especially if you want to build apps that need real time stuff.
75
108
 
76
109
  ## TODO - Whats Coming
77
110
 
78
- + Clean up some APIs
79
111
  + Add Documentation
80
112
  + Video Screencasts
81
- + More Generators
82
- + Example Rails Project
113
+ + Add more features to Kontax
114
+ + More documentation on Services
83
115
 
84
116
  ## Contributing
85
117
 
@@ -90,5 +122,4 @@ Services are very modular and they can be applied to multiple widgets in a page
90
122
  5. Create new Pull Request
91
123
 
92
124
  ## Credits
93
- Gem developed by [Zack Siri](http://github.com/zacksiri) of [Artellectual](http://www.artellectual.com)
94
-
125
+ Gem developed by [Zack Siri](http://github.com/zacksiri) of [Artellectual](http://www.artellectual.com)
@@ -2,7 +2,7 @@ class Transponder.Response
2
2
  payload: {}
3
3
 
4
4
  constructor: ->
5
- $(document).on 'ajax:complete', (event, xhr, status) =>
5
+ $(document).ajaxComplete (event, xhr, status) =>
6
6
  if xhr.getResponseHeader('Content-Type') is 'application/transmission'
7
7
  @payload.raw = JSON.parse(@cleanContent(xhr.responseText))
8
8
  element = @payload.raw[0]
@@ -25,7 +25,7 @@ module Transponder
25
25
  def add_service_to_manifest
26
26
  manifest_file = File.join(javascripts_path, options[:module_name], 'initializers/manifest.coffee')
27
27
  insert_into_file manifest_file,
28
- " $(body).trigger '#{options[:module_name].downcase}:services:#{file_name.downcase}'\n",
28
+ " $('body').trigger '#{options[:module_name].downcase}:services:#{file_name.downcase}'\n",
29
29
  after: "#{options[:module_name].camelize}.services_manifest = ->\n"
30
30
  end
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module Transponder
2
- VERSION = "0.9.5"
2
+ VERSION = "0.9.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transponder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zack Siri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-04 00:00:00.000000000 Z
11
+ date: 2013-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-rails