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 +4 -4
- data/lib/carte/client.css +1 -1
- data/lib/carte/client/models/card.coffee +6 -0
- data/lib/carte/client/models/card_histories.coffee +19 -0
- data/lib/carte/client/models/card_history.coffee +5 -0
- data/lib/carte/client/models/cards.coffee +2 -0
- data/lib/carte/client/router.coffee +7 -6
- data/lib/carte/client/views/card.cjsx +42 -16
- data/lib/carte/client/views/cards.cjsx +1 -1
- data/lib/carte/client/views/content.cjsx +14 -1
- data/lib/carte/client/views/list.cjsx +51 -6
- data/lib/carte/client/views/message.cjsx +1 -1
- data/lib/carte/server.rb +8 -3
- data/package.json +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10e4c87356c4d71772d5534102215a6ebee7bfa6
|
4
|
+
data.tar.gz: dd8e7c1fd85b46173178451cd93c113bec50f86f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16593c18c820bc4a76eae61d999daf1fe18ec8b4f6d6d8f5f17846dda80e26c4e370efc770ccf6c0b885c1a6ab25cacd0b7f2de9ca44ea3a3c407f55ec58497c
|
7
|
+
data.tar.gz: e9b46b510b2a640e17a2390f0a1e79f5fe9626bf0f6eee9c8637958031908716511a3db7fbe19e4689680bd2d776484371724fa059e141d8435863ae6fe6c50c
|
data/lib/carte/client.css
CHANGED
@@ -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
|
@@ -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
|
-
|
33
|
-
|
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
|
-
|
43
|
-
|
44
|
-
<
|
45
|
-
<
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
+
|
63
|
+
|
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
|
+
|
72
|
+
{@props.card.get('version')}
|
73
|
+
</span>
|
74
|
+
}
|
54
75
|
</div>
|
55
76
|
<div className="carte-card-content">
|
56
|
-
|
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={"#/" +
|
135
|
-
|
136
|
-
|
137
|
-
|
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
|
-
|
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">
|
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
|
-
{
|
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
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.
|
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-
|
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
|