carte-server 1.0.7 → 1.0.8

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: d81ce3e8c26a94618aac1527f475ba4a8fae8a7a
4
- data.tar.gz: c555caad49ebb424cd41bcd65a2328cab83d3374
3
+ metadata.gz: 10e4c87356c4d71772d5534102215a6ebee7bfa6
4
+ data.tar.gz: dd8e7c1fd85b46173178451cd93c113bec50f86f
5
5
  SHA512:
6
- metadata.gz: 820d0748a05bc04fcfd3aa45d48c85cf71799157ae7996b0c13aa07c72762bc1ea6ddeef8ee63de61a9a012f364bb38e72ad4c58e4a8e0680e07c25fe7c6b2b2
7
- data.tar.gz: 62f67eb92f36ffcccfc4f92b87f18e3e8b0604c4d9f2399367e118a8ce18f3f42406c404e5a500be33f325e4e7a6a0677bf2e28e2cf5762d7c4daea8d1db2b72
6
+ metadata.gz: 16593c18c820bc4a76eae61d999daf1fe18ec8b4f6d6d8f5f17846dda80e26c4e370efc770ccf6c0b885c1a6ab25cacd0b7f2de9ca44ea3a3c407f55ec58497c
7
+ data.tar.gz: e9b46b510b2a640e17a2390f0a1e79f5fe9626bf0f6eee9c8637958031908716511a3db7fbe19e4689680bd2d776484371724fa059e141d8435863ae6fe6c50c
data/lib/carte/client.css CHANGED
@@ -48,7 +48,7 @@ ul.nav-pills li a {
48
48
  padding: 5px;
49
49
  }
50
50
 
51
- .list-group-item {
51
+ .carte-card-height {
52
52
  height: 200px;
53
53
  }
54
54
 
@@ -1,10 +1,15 @@
1
1
  Backbone = require('backbone')
2
2
  config = require('../config')
3
3
  querystring = require('querystring')
4
+ $ = require('jquery')
4
5
 
5
6
  module.exports = class Card extends Backbone.Model
7
+ modelName: 'Card'
8
+
6
9
  idAttribute: 'title'
7
10
 
11
+ query: {}
12
+
8
13
  isNew: ()->
9
14
  @_isNew
10
15
 
@@ -13,6 +18,7 @@ module.exports = class Card extends Backbone.Model
13
18
  url = '/cards.json'
14
19
  else
15
20
  url = '/cards/' + encodeURIComponent(@get('title')) + '.json'
21
+ url = url + '?' + $.param(@query) if @query != {}
16
22
  config.root_path + config.api_path + url
17
23
 
18
24
  parse: (response)->
@@ -0,0 +1,19 @@
1
+ Backbone = require('backbone')
2
+ CardHistoryModel = require('./card_history')
3
+ $ = require('jquery')
4
+ config = require('../config')
5
+
6
+ module.exports = class CardHistories extends Backbone.Collection
7
+ collectionName: 'CardHistories'
8
+
9
+ model: CardHistoryModel
10
+
11
+ query: {}
12
+
13
+ url: ()->
14
+ url = '/cards/' + @title + '/history.json'
15
+ config.root_path + config.api_path + url
16
+
17
+ parse: (response)->
18
+ @pagination = response.pagination
19
+ response.history
@@ -0,0 +1,5 @@
1
+ Card = require './card'
2
+
3
+ module.exports = class CardHistory extends Card
4
+ modelName: 'CardHistory'
5
+ idAttribute: 'version'
@@ -4,6 +4,8 @@ $ = require('jquery')
4
4
  config = require('../config')
5
5
 
6
6
  module.exports = class Cards extends Backbone.Collection
7
+ collectionName: 'Cards'
8
+
7
9
  model: CardModel
8
10
  query: {}
9
11
  url: ()->
@@ -4,8 +4,8 @@ Backbone = require('backbone')
4
4
  module.exports = class Router extends Backbone.Router
5
5
  routes:
6
6
  '': 'list'
7
- 'slideshow': 'slideshow'
8
7
  ':title': 'show'
8
+ ':title/history': 'history'
9
9
 
10
10
  list: (string)->
11
11
  console.log '[router] list', string
@@ -13,12 +13,13 @@ module.exports = class Router extends Backbone.Router
13
13
  @current = 'list'
14
14
  @query = querystring.parse(string)
15
15
 
16
- show: (title)->
16
+ show: (title, string)->
17
17
  console.log '[router] show', title
18
18
  @current = 'show'
19
19
  @title = title
20
-
21
- slideshow: (string)->
22
- console.log 'slideshow', string
23
- @current = 'slideshow'
24
20
  @query = querystring.parse(string)
21
+
22
+ history: (title)->
23
+ console.log '[router] history', title
24
+ @current = 'history'
25
+ @title = title
@@ -29,31 +29,57 @@ module.exports = React.createClass
29
29
  helpers.isMobile() || @state.showTools
30
30
 
31
31
  render: ->
32
- <div className='col-sm-4 col-xs-12 list-group' onMouseOver={@onMouseOver} onMouseLeave={@onMouseLeave}>
33
- <div className='list-group-item'>
32
+ context = @props.card.query.context
33
+ <div
34
+ className={
35
+ classnames(
36
+ 'list-group',
37
+ 'col-sm-4': context != 'none',
38
+ 'col-xs-12': context != 'none',
39
+ 'col-sm-12': context == 'none'
40
+ )
41
+ }
42
+ onMouseOver={@onMouseOver}
43
+ onMouseLeave={@onMouseLeave}
44
+ >
45
+ <div className={classnames('list-group-item', 'carte-card-height': context != 'none')}>
34
46
  <div className="carte-card-header">
35
47
  {
36
- if @props.card.get('focused')
48
+ if @props.card.get('focused') || @props.card.query.context == 'none'
37
49
  <i className='glyphicon glyphicon-star' />
38
50
  }
39
51
  <strong>
40
52
  {@props.card.get('title')}
41
53
  </strong>
42
- <span className={classnames('pull-right': true, 'tools': true, 'carte-hidden': !@showTools())}>
43
- <ModalTrigger modal={<Edit card={@props.card} />}>
44
- <a href="javascript:void(0)">
45
- <i className='glyphicon glyphicon-edit' />
46
- </a>
47
- </ModalTrigger>
48
- &nbsp;
49
- &nbsp;
50
- <a href={'#/' + encodeURIComponent(@props.card.get('title'))}>
51
- <i className='glyphicon glyphicon-link' />
52
- </a>
53
- </span>
54
+ {
55
+ if @props.card.modelName == 'Card'
56
+ <span className={classnames('pull-right': true, 'tools': true, 'carte-hidden': !@showTools())}>
57
+ <ModalTrigger modal={<Edit card={@props.card} />}>
58
+ <a href="javascript:void(0)">
59
+ <i className='glyphicon glyphicon-edit' />
60
+ </a>
61
+ </ModalTrigger>
62
+ &nbsp;
63
+ &nbsp;
64
+ <a href={'#/' + encodeURIComponent(@props.card.get('title'))}>
65
+ <i className='glyphicon glyphicon-link' />
66
+ </a>
67
+ </span>
68
+ else
69
+ <span className={classnames('pull-right': true)}>
70
+ <i className="fa fa-clock-o" />
71
+ &nbsp;
72
+ {@props.card.get('version')}
73
+ </span>
74
+ }
54
75
  </div>
55
76
  <div className="carte-card-content">
56
- <div dangerouslySetInnerHTML={__html: markdownIt.render @props.card.get('content')} />
77
+ {
78
+ if @props.card.fetching
79
+ <i className='glyphicon glyphicon-refresh glyphicon-refresh-animate' />
80
+ else
81
+ <div dangerouslySetInnerHTML={__html: markdownIt.render @props.card.get('content') || ''} />
82
+ }
57
83
  </div>
58
84
  <div className={classnames('carte-hidden': !@showTools())}>
59
85
  {
@@ -35,5 +35,5 @@ module.exports = React.createClass
35
35
  <i className='glyphicon glyphicon-alert' /> {@state.error.status} {@state.error.statusText}
36
36
  </Message>
37
37
  else
38
- cards = @props.cards.map (card)-> <Card key={card.get("title")} card={card} />
38
+ cards = @props.cards.map (card)-> <Card key={card.get("title") + card.get("version")} card={card} />
39
39
  <div className='row'>{cards}</div>
@@ -4,6 +4,7 @@ React = require('react')
4
4
  List = require('./list')
5
5
  Slideshow = require('./slideshow')
6
6
  CardCollection = require('../models/cards')
7
+ CardHistoryCollection = require('../models/card_histories')
7
8
  CardModel = require('../models/card')
8
9
  String = require('string')
9
10
  config = require('../config')
@@ -34,7 +35,7 @@ module.exports = React.createClass
34
35
  if cards.query.mode == 'flash'
35
36
  cards.query.auto = 'off' if !cards.query.auto
36
37
  cards.query.hide = 'none' if !cards.query.hide
37
- document.title = config.title + '、スライドショー'
38
+ document.title = config.title + '、フラッシュ'
38
39
  <Slideshow key='slideshow' router={@props.router} cards={cards} />
39
40
  else
40
41
  document.title = config.title
@@ -43,8 +44,11 @@ module.exports = React.createClass
43
44
  cards = new CardCollection()
44
45
  cards.fetching = true
45
46
  card = new CardModel(title: @props.router.title)
47
+ card.query = $.extend {}, {context: 'updated_at'}, @props.router.query
48
+ card.fetching = true
46
49
  card.fetch
47
50
  success: (card)->
51
+ card.fetching = false
48
52
  for left in card.get("lefts")
49
53
  cardModel = new CardModel(left)
50
54
  cardModel.set 'focused', false
@@ -60,6 +64,15 @@ module.exports = React.createClass
60
64
  cards.fetching = false
61
65
  document.title = config.title + '、' + card.get('title')
62
66
  <List key='show' cards={cards} card={card} />
67
+ when "history"
68
+ console.log '[views/content] history', @props
69
+ cards = new CardHistoryCollection()
70
+ console.log cards
71
+ cards.title = @props.router.title
72
+ cards.fetching = true
73
+ cards.fetch success: ()-> cards.fetching = false
74
+ document.title = config.title + '、ヒストリー'
75
+ <List key='list' router={@props.router} cards={cards} />
63
76
  else
64
77
  null
65
78
  }
@@ -3,6 +3,7 @@ $ = require('jquery')
3
3
  Backbone = require('backbone')
4
4
  React = require('react')
5
5
  Cards = require('./cards')
6
+ Card = require('./card')
6
7
  CardCollection = require('../models/cards')
7
8
  Pagination = require('./pagination')
8
9
  helpers = require('../helpers')
@@ -39,7 +40,7 @@ module.exports = React.createClass
39
40
 
40
41
  render: ->
41
42
  <div className="container carte-list">
42
- {if !@props.card
43
+ {if !@props.card && @props.cards.collectionName == 'Cards'
43
44
  <div className="row">
44
45
  <div className="col-sm-4">
45
46
  <ul className="nav nav-pills">
@@ -127,21 +128,65 @@ module.exports = React.createClass
127
128
  </div>
128
129
  </div>
129
130
  else
131
+ if @props.card
132
+ title = @props.card.get('title')
133
+ else
134
+ title = @props.router.title
130
135
  <div className="row">
131
136
  <div className="col-sm-12">
132
137
  <ul className="nav nav-pills">
133
138
  <li>
134
- <a href={"#/" + @props.card.get('title')}>
135
- <strong>
136
- {@props.card.get('title')}
137
- </strong>
139
+ <a href={"#/" + title + '?context=title'}>
140
+ {
141
+ if @props.card && @props.card.query.context == 'title'
142
+ <strong>A to Z</strong>
143
+ else
144
+ <span>A to Z</span>
145
+ }
146
+ </a>
147
+ </li>
148
+ <li>
149
+ <a href={"#/" + title + '?context=updated_at'}>
150
+ {
151
+ if @props.card && @props.card.query.context == 'updated_at'
152
+ <strong>Latest</strong>
153
+ else
154
+ <span>Latest</span>
155
+ }
156
+ </a>
157
+ </li>
158
+ <li>
159
+ <a href={"#/" + title + '?context=none'}>
160
+ {
161
+ if @props.card && @props.card.query.context == 'none'
162
+ <strong>Detail</strong>
163
+ else
164
+ <span>Detail</span>
165
+ }
166
+ </a>
167
+ </li>
168
+ <li>
169
+ <a href={"#/" + title + '/history'}>
170
+ {
171
+ if @props.cards.collectionName == 'CardHistories'
172
+ <strong>History</strong>
173
+ else
174
+ <span>History</span>
175
+ }
138
176
  </a>
139
177
  </li>
140
178
  </ul>
141
179
  </div>
142
180
  </div>
143
181
  }
144
- <Cards cards={@props.cards} card={@props.card} />
182
+ {
183
+ if @props.card && @props.card.query.context == 'none'
184
+ <div className='row'>
185
+ <Card key={@props.card.get("title")} card={@props.card} />
186
+ </div>
187
+ else
188
+ <Cards cards={@props.cards} card={@props.card} />
189
+ }
145
190
  {
146
191
  if !@props.card && helpers.isMobile()
147
192
  <div className="row">
@@ -11,7 +11,7 @@ module.exports = React.createClass
11
11
  for i in [1..9]
12
12
  <div key={i} className='col-sm-4'>
13
13
  <div className='list-group'>
14
- <div className='list-group-item'>
14
+ <div className='list-group-item carte-card-height'>
15
15
  {@props.children}
16
16
  </div>
17
17
  </div>
data/lib/carte/server.rb CHANGED
@@ -84,8 +84,8 @@ module Carte
84
84
  {
85
85
  card: card.as_json(only: %w(title content version tags)).update(
86
86
  version: card.version,
87
- lefts: card.lefts(4).as_json(only: %w(title content version tags)),
88
- rights: card.rights(4).as_json(only: %w(title content version tags))
87
+ lefts: card.lefts(4, context).as_json(only: %w(title content version tags)),
88
+ rights: card.rights(4, context).as_json(only: %w(title content version tags))
89
89
  )
90
90
  }.to_json
91
91
  end
@@ -123,7 +123,12 @@ module Carte
123
123
  get '/cards/:title/history.json' do
124
124
  card = Card.where(title: params[:title]).first
125
125
  halt 404 if card.nil?
126
- {history: card.histories.as_json(only: %w(title content version tags))}.to_json
126
+ {
127
+ history: [
128
+ card.as_json(only: %w(title content version tags)).update(version: card.version),
129
+ card.histories.desc(:version).as_json(only: %w(title content version tags))
130
+ ].flatten
131
+ }.to_json
127
132
  end
128
133
 
129
134
  get '/tags.json' do
data/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "carte-client",
3
3
  "description": "something like dictionary, wiki, or information card",
4
- "version": "1.0.7",
4
+ "version": "1.0.8",
5
5
  "main": "lib/carte.coffee",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carte-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - tily
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-17 00:00:00.000000000 Z
11
+ date: 2015-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -264,6 +264,8 @@ files:
264
264
  - lib/carte/client/config.coffee
265
265
  - lib/carte/client/helpers.coffee
266
266
  - lib/carte/client/models/card.coffee
267
+ - lib/carte/client/models/card_histories.coffee
268
+ - lib/carte/client/models/card_history.coffee
267
269
  - lib/carte/client/models/cards.coffee
268
270
  - lib/carte/client/router.coffee
269
271
  - lib/carte/client/tasks.coffee