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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 578b63ee21c185a3eb2a97d8c12527666fe67004
4
- data.tar.gz: 9d22c1637d7c67624ae59d45b4eb976b04528e01
3
+ metadata.gz: 2c467e1cd99ce718cb1debd0ccec6d12ced89426
4
+ data.tar.gz: 83d79a8bc6e1fadadb298dba101fc0c90ba16464
5
5
  SHA512:
6
- metadata.gz: 3ef6e662bb70e336fc4440e5722161a5431d94f1fa2b85e63ddcb13928e1ac29f12c8cd249b75f6a79caa509a899181d47eb5b9fbb0281dbf7d0c5f306be6ded
7
- data.tar.gz: 947df6a57f8cb370607a05ac1536582f461a23caa48623ad4a9bb3bd9ca7be00dbc1e0c1a8922c8c575402e403c86a7e9a3a60224b4825a465ed7835da46fe32
6
+ metadata.gz: 36231df14cd93e7afd5596b694051b27c71a9592ee95bf1f44bcbe12ac86741b3f2645067bd62d89b3286743b58b7f6d001d804087aa19cc644d6b2711f9515c
7
+ data.tar.gz: 332122281586ce0350b0a616948dfd8b8671a19d3eae60d55dbbed6b0a150ea5f20795709e0c3432baf18022ccb6777597d15a4320918a75cb782d6c267346c8
data/.gitignore CHANGED
@@ -15,5 +15,6 @@ mkmf.log
15
15
  /node_modules/
16
16
  /public/app.js
17
17
  /public/app.html
18
+ /public/vendor
18
19
  /lib/carte/shared/custom.json
19
20
  .env
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
@@ -34,4 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency "mongoid-simple-tags"
35
35
  spec.add_dependency "mongoid-geospatial"
36
36
  spec.add_dependency "redcarpet"
37
+ spec.add_dependency "pry"
37
38
  end
@@ -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 'coffee-reactify'
49
- .transform 'debowerify'
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]
@@ -11,6 +11,6 @@ module.exports = class Cards extends Backbone.Collection
11
11
  config.root_path + config.api_path + url
12
12
  parse: (response)->
13
13
  console.log response
14
- @page = response.page
14
+ @pagination = response.pagination
15
15
  console.log @page
16
16
  response.cards
@@ -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.page
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.page
20
- if @props.cards.page.current > 1
21
- href = "#/?" + @pageParam(@props.cards.page.current - 1)
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.page.total)
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.page
34
- <a href={"#/?" + @pageParam(@props.cards.page.current)} onClick={helpers.reload} style={{padding:'6px 12px'}}>
35
- {@props.cards.page.current} / {@props.cards.page.total}
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.page
46
- if @props.cards.page.current < @props.cards.page.total
47
- href = "#/?" + @pageParam(@props.cards.page.current + 1)
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
@@ -67,25 +67,30 @@ module Carte
67
67
 
68
68
  get '/cards.json' do
69
69
  cards = search(params)
70
- if cards.respond_to?(:current_page) && cards.respond_to?(:total_pages)
71
- current_page = cards.current_page.to_i
72
- total_pages = cards.total_pages
73
- end
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
- {card: {id: card.id, title: card.title, content: card.content, version: card.version, tags: card.tags, lefts: card.lefts(4), rights: card.rights(4)}}.to_json
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
- {card: {id: card.id}}.to_json
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=1)
53
- ids = []
54
- count = self.class.all.count
55
- 1.upto(size) do |i|
56
- ids << (self.id - i > 0 ? self.id - i : count + (self.id - i))
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
- self.class.in(id: ids)
59
+ result
59
60
  end
60
-
61
- def rights(size=1)
62
- ids = []
63
- count = self.class.all.count
64
- 1.upto(size) do |i|
65
- ids << (self.id + i <= count ? self.id + i : self.id + i - count)
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
- self.class.in(id: ids)
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
@@ -1,4 +1,5 @@
1
1
  require 'carte/server'
2
+ require 'pry'
2
3
  include Carte::Server::Models
3
4
 
4
5
  namespace :carte do
@@ -57,4 +58,9 @@ namespace :carte do
57
58
  card.save!
58
59
  end
59
60
  end
61
+
62
+ desc 'start console'
63
+ task :console do
64
+ binding.pry
65
+ end
60
66
  end
@@ -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.21",
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.21
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-08 00:00:00.000000000 Z
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
File without changes