carte-server 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +2 -1
- data/carte.gemspec +1 -0
- data/lib/carte.coffee +4 -3
- data/lib/carte/client/models/cards.coffee +1 -1
- data/lib/carte/client/views/list.cjsx +1 -1
- data/lib/carte/client/views/pagination.cjsx +10 -10
- data/lib/carte/server.rb +14 -9
- data/lib/carte/server/models/card.rb +16 -14
- data/lib/carte/server/models/history.rb +2 -0
- data/lib/carte/server/tasks.rb +6 -0
- data/package.json +1 -2
- metadata +16 -3
- data/lib/carte/shared/.keep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c467e1cd99ce718cb1debd0ccec6d12ced89426
|
4
|
+
data.tar.gz: 83d79a8bc6e1fadadb298dba101fc0c90ba16464
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36231df14cd93e7afd5596b694051b27c71a9592ee95bf1f44bcbe12ac86741b3f2645067bd62d89b3286743b58b7f6d001d804087aa19cc644d6b2711f9515c
|
7
|
+
data.tar.gz: 332122281586ce0350b0a616948dfd8b8671a19d3eae60d55dbbed6b0a150ea5f20795709e0c3432baf18022ccb6777597d15a4320918a75cb782d6c267346c8
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -9,6 +9,8 @@ Something like dictionary, wiki, or information card.
|
|
9
9
|
|
10
10
|
![](screenshot.png)
|
11
11
|
|
12
|
+
You can try carte on [sandbox](http://carte-sandbox.herokuapp.com/#/). There is also [a French-Japanese dictionary version](https://carte-francais.herokuapp.com/#/).
|
13
|
+
|
12
14
|
## Features
|
13
15
|
|
14
16
|
* Manage your data fragments with cards
|
@@ -16,7 +18,6 @@ Something like dictionary, wiki, or information card.
|
|
16
18
|
* View your card with the cards around it (like paper dictionary)
|
17
19
|
* No user concept, super simple system like wiki
|
18
20
|
|
19
|
-
You can try carte on [sandbox](http://carte-sandbox.herokuapp.com/#/).
|
20
21
|
Japanese introduction is [here](http://tily.tumblr.com/post/117678137942/carte).
|
21
22
|
|
22
23
|
## Components
|
data/carte.gemspec
CHANGED
data/lib/carte.coffee
CHANGED
@@ -8,6 +8,8 @@ browserify = require 'browserify'
|
|
8
8
|
watchify = require 'watchify'
|
9
9
|
uglify = require 'gulp-uglify'
|
10
10
|
streamify = require 'gulp-streamify'
|
11
|
+
coffeeReactify = require 'coffee-reactify'
|
12
|
+
browserifyCss = require 'browserify-css'
|
11
13
|
_ = require 'lodash'
|
12
14
|
jade = require 'gulp-jade'
|
13
15
|
rename = require 'gulp-rename'
|
@@ -45,9 +47,8 @@ module.exports = class Carte
|
|
45
47
|
entries: [__dirname + '/carte/client.coffee']
|
46
48
|
extensions: ['.coffee', '.js', '.cjsx', '.css']
|
47
49
|
browserify
|
48
|
-
.transform
|
49
|
-
.transform
|
50
|
-
.transform 'browserify-css',
|
50
|
+
.transform coffeeReactify
|
51
|
+
.transform browserifyCss,
|
51
52
|
rootDir: 'public'
|
52
53
|
processRelativeUrl: (relativeUrl)->
|
53
54
|
stripQueryStringAndHashFromPath = (url)-> url.split('?')[0].split('#')[0]
|
@@ -62,7 +62,7 @@ module.exports = React.createClass
|
|
62
62
|
<ul className="nav nav-pills pull-right">
|
63
63
|
<li>
|
64
64
|
{
|
65
|
-
if @props.cards.
|
65
|
+
if @props.cards.pagination
|
66
66
|
<a onClick={helpers.reload} href={"#/?" + @randomParam()} style={{padding:'6px 12px'}}>
|
67
67
|
<i className="glyphicon glyphicon-refresh" />
|
68
68
|
</a>
|
@@ -16,11 +16,11 @@ module.exports = React.createClass
|
|
16
16
|
<ul className="nav nav-pills pull-right">
|
17
17
|
<li>
|
18
18
|
{
|
19
|
-
if @props.cards.
|
20
|
-
if @props.cards.
|
21
|
-
href = "#/?" + @pageParam(@props.cards.
|
19
|
+
if @props.cards.pagination
|
20
|
+
if @props.cards.pagination.current_page > 1
|
21
|
+
href = "#/?" + @pageParam(@props.cards.pagination.current_page - 1)
|
22
22
|
else
|
23
|
-
href = "#/?" + @pageParam(@props.cards.
|
23
|
+
href = "#/?" + @pageParam(@props.cards.pagination.total_pages)
|
24
24
|
else
|
25
25
|
href = "javascript:void(0)"
|
26
26
|
<a href={href} aria-label="Previous" style={{padding:'6px 12px'}}>
|
@@ -30,9 +30,9 @@ module.exports = React.createClass
|
|
30
30
|
</li>
|
31
31
|
<li style={width:'7.5em',textAlign:'center'}>
|
32
32
|
{
|
33
|
-
if @props.cards.
|
34
|
-
<a href={"#/?" + @pageParam(@props.cards.
|
35
|
-
{@props.cards.
|
33
|
+
if @props.cards.pagination
|
34
|
+
<a href={"#/?" + @pageParam(@props.cards.pagination.current_page)} onClick={helpers.reload} style={{padding:'6px 12px'}}>
|
35
|
+
{@props.cards.pagination.current_page} / {@props.cards.pagination.total_pages}
|
36
36
|
</a>
|
37
37
|
else
|
38
38
|
<a href="javascript:void(0)" style={{padding:'6px 12px'}}>
|
@@ -42,9 +42,9 @@ module.exports = React.createClass
|
|
42
42
|
</li>
|
43
43
|
<li>
|
44
44
|
{
|
45
|
-
if @props.cards.
|
46
|
-
if @props.cards.
|
47
|
-
href = "#/?" + @pageParam(@props.cards.
|
45
|
+
if @props.cards.pagination
|
46
|
+
if @props.cards.pagination.current_page < @props.cards.pagination.total_pages
|
47
|
+
href = "#/?" + @pageParam(@props.cards.pagination.current_page + 1)
|
48
48
|
else
|
49
49
|
href = "#/?" + @pageParam(1)
|
50
50
|
else
|
data/lib/carte/server.rb
CHANGED
@@ -67,25 +67,30 @@ module Carte
|
|
67
67
|
|
68
68
|
get '/cards.json' do
|
69
69
|
cards = search(params)
|
70
|
-
|
71
|
-
|
72
|
-
total_pages
|
73
|
-
|
74
|
-
cards = cards.map {|card| {id: card.id, title: card.title, content: card.content, version: card.version, tags: card.tags}}
|
75
|
-
{cards: cards, page: {current: current_page, total: total_pages}}.to_json
|
70
|
+
{
|
71
|
+
cards: cards.as_json(only: %w(title content version tags)),
|
72
|
+
pagination: {current_page: cards.current_page, total_pages: cards.total_pages, total_entries: cards.total_entries}
|
73
|
+
}.to_json
|
76
74
|
end
|
77
75
|
|
78
76
|
get '/cards/:title.json' do
|
77
|
+
context = (params[:context] && %w(title created_at updated_at).include?(params[:context])) ? params[:context] : 'created_at'
|
79
78
|
card = Card.where(title: params[:title]).first
|
80
79
|
halt 404 if card.nil?
|
81
|
-
{
|
80
|
+
{
|
81
|
+
card: card.as_json(only: %w(title content version tags)).update(
|
82
|
+
version: card.version,
|
83
|
+
lefts: card.lefts(4).as_json(only: %w(title content version tags)),
|
84
|
+
rights: card.rights(4).as_json(only: %w(title content version tags))
|
85
|
+
)
|
86
|
+
}.to_json
|
82
87
|
end
|
83
88
|
|
84
89
|
post '/cards.json' do
|
85
90
|
card = Card.new(json_data.slice('title', 'content', 'tags'))
|
86
91
|
if card.save
|
87
92
|
status 201
|
88
|
-
{
|
93
|
+
{}.to_json
|
89
94
|
else
|
90
95
|
status 400
|
91
96
|
{card: {errors: card.errors}}.to_json
|
@@ -114,7 +119,7 @@ module Carte
|
|
114
119
|
get '/cards/:title/history.json' do
|
115
120
|
card = Card.where(title: params[:title]).first
|
116
121
|
halt 404 if card.nil?
|
117
|
-
{history: card.histories}.to_json
|
122
|
+
{history: card.histories.as_json(only: %w(title content version tags))}.to_json
|
118
123
|
end
|
119
124
|
|
120
125
|
get '/tags.json' do
|
@@ -48,23 +48,25 @@ module Carte
|
|
48
48
|
def self.random
|
49
49
|
self.near(random_point: [Random.rand, 0])
|
50
50
|
end
|
51
|
-
|
52
|
-
def lefts(size
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
|
52
|
+
def lefts(size, context=:created_at)
|
53
|
+
result = Card.lt(context => self.send(context)).limit(size).to_a
|
54
|
+
shortage = size - result.size
|
55
|
+
if shortage > 0
|
56
|
+
addition = self.class.lte(context => Card.max(context)).gt(context => self.send(context)).limit(shortage).to_a
|
57
|
+
result = addition + result
|
57
58
|
end
|
58
|
-
|
59
|
+
result
|
59
60
|
end
|
60
|
-
|
61
|
-
def rights(size
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
|
62
|
+
def rights(size, context=:created_at)
|
63
|
+
result = self.class.gt(context => self.send(context)).limit(size).to_a
|
64
|
+
shortage = size - result.size
|
65
|
+
if shortage > 0
|
66
|
+
addition = self.class.gt(context => 0).lt(context => self.send(context)).limit(shortage).to_a
|
67
|
+
result = result + addition
|
66
68
|
end
|
67
|
-
|
69
|
+
result
|
68
70
|
end
|
69
71
|
end
|
70
72
|
end
|
@@ -7,12 +7,14 @@ module Carte
|
|
7
7
|
field :title, type: String
|
8
8
|
field :content, type: String
|
9
9
|
field :version, type: Integer
|
10
|
+
field :tags, type: Array
|
10
11
|
belongs_to :card
|
11
12
|
|
12
13
|
before_create do
|
13
14
|
self.title = self.card.title
|
14
15
|
self.content = self.card.content
|
15
16
|
self.version = self.card.version
|
17
|
+
self.tags = self.card.tags
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/carte/server/tasks.rb
CHANGED
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": "0.0.
|
4
|
+
"version": "0.0.22",
|
5
5
|
"main": "lib/carte.coffee",
|
6
6
|
"scripts": {
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1"
|
@@ -25,7 +25,6 @@
|
|
25
25
|
"coffee-reactify": "^3.0.0",
|
26
26
|
"coffee-script": "^1.9.2",
|
27
27
|
"coffeeify": "^1.0.0",
|
28
|
-
"debowerify": "^1.2.1",
|
29
28
|
"extend": "^2.0.1",
|
30
29
|
"font-awesome": "^4.3.0",
|
31
30
|
"fs-extra": "^0.18.2",
|
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: 0.0.
|
4
|
+
version: 0.0.22
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -220,6 +220,20 @@ dependencies:
|
|
220
220
|
- - '>='
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: pry
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - '>='
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :runtime
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - '>='
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
223
237
|
description: something like dictionary, wiki, or information card
|
224
238
|
email:
|
225
239
|
- tidnlyam@gmail.com
|
@@ -267,7 +281,6 @@ files:
|
|
267
281
|
- lib/carte/server/validators/array_validator.rb
|
268
282
|
- lib/carte/server/version.rb
|
269
283
|
- lib/carte/server/views/cards.builder
|
270
|
-
- lib/carte/shared/.keep
|
271
284
|
- lib/carte/shared/default.json
|
272
285
|
- mongoid.yml
|
273
286
|
- nginx.conf
|
data/lib/carte/shared/.keep
DELETED
File without changes
|