carte-server 0.0.12 → 0.0.13

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: ba996bbb2d71cf1b95ae1955737496ffe9b2a27a
4
- data.tar.gz: 19aa30df9a3807971d76e5a7a256eca9fb554228
3
+ metadata.gz: d197ea3d1133844e5dd56466724f421dad8cf957
4
+ data.tar.gz: ef1e33d03996bbcef1eccd41a386e5ec7787b728
5
5
  SHA512:
6
- metadata.gz: c12da1320c1311ae74b500d6de2e1ff903adc5aeb7b90a87ca2e05881b15a03c4bef831b07c8c1edfb419dc6ac78321ab2923e657964feb8137af3a10e56c284
7
- data.tar.gz: ae179b634d6bf222611497408d54fe21e31255fba216ca8810db75a26b4961ffed8560b205f9ffff512b81e27b7deb78f07b2198d623524459064566af672ddd
6
+ metadata.gz: c28c72d2e4ba717cfe840d3417d10fe3703936defb7185f069800a9b92008031574cce3328eadcb1117572d20b5481157aed8186204153e935a2e473919ba3dc
7
+ data.tar.gz: d62efdbf04e13578de0060504acb695b8405c382581f22bf05ff5dad21367409d48c109a6c6f0c129135ad92f1c8c4d9a2f6cad0d1db823fbc2d1dc20421463f
data/.gitignore CHANGED
@@ -14,4 +14,4 @@
14
14
  mkmf.log
15
15
  /node_modules/
16
16
  /public/app.js
17
- /lib/carte/shared/config.json
17
+ /lib/carte/shared/custom.json
@@ -1,8 +1,10 @@
1
1
  {
2
- "title": "Carte Sandbox",
2
+ "title": "Carte Sandbox (custom)",
3
3
  "description": "Sandbox for Carte",
4
4
  "public_folder": "public",
5
5
  "script_path": "public/app.js",
6
6
  "link_color": "yellow",
7
+ "menu_items": ["latest", "random", "atoz"],
8
+ "default_query": {"sort": "updated_at", "order": "desc"},
7
9
  "api_path": ""
8
10
  }
@@ -24,7 +24,7 @@ module.exports = class Carte
24
24
 
25
25
  build: (options)->
26
26
  config = require(options.config)
27
- fs.writeFileSync(__dirname + '/carte/shared/config.json', JSON.stringify(config))
27
+ fs.writeFileSync(__dirname + '/carte/shared/custom.json', JSON.stringify(config))
28
28
  dir = path.dirname config.script_path
29
29
  file = path.basename config.script_path
30
30
  minify = options.minify
@@ -0,0 +1,4 @@
1
+ $ = require('jquery')
2
+ _default = require('../shared/default')
3
+ custom = require('../shared/custom')
4
+ module.exports = $.extend _default, custom
@@ -1,5 +1,5 @@
1
1
  Backbone = require('backbone')
2
- config = require('../../shared/config.json')
2
+ config = require('../config')
3
3
  querystring = require('querystring')
4
4
 
5
5
  module.exports = class Card extends Backbone.Model
@@ -1,7 +1,7 @@
1
1
  Backbone = require('backbone')
2
2
  CardModel = require('./card')
3
3
  $ = require('jquery')
4
- config = require('../../shared/config.json')
4
+ config = require('../config')
5
5
 
6
6
  module.exports = class Cards extends Backbone.Collection
7
7
  model: CardModel
@@ -46,7 +46,7 @@ module.exports = React.createClass
46
46
  </ModalTrigger>
47
47
  &nbsp;
48
48
  &nbsp;
49
- <a href={'#/' + @props.card.get('title')}>
49
+ <a href={'#/' + encodeURIComponent(@props.card.get('title'))}>
50
50
  <i className='glyphicon glyphicon-link' />
51
51
  </a>
52
52
  </span>
@@ -11,10 +11,10 @@ module.exports = React.createClass
11
11
  componentDidMount: ()->
12
12
  console.log 'component did mount'
13
13
  @props.cards.on 'sync', @forceUpdate.bind(@, null)
14
- @props.card.on 'sync', @forceUpdate.bind(@, null)
15
- @props.card.on 'error', (model, response)=>
16
- @setState error: response
17
- @forceUpdate.bind(@, null)
14
+ if @props.card
15
+ @props.card.on 'error', (model, response)=>
16
+ @setState error: response
17
+ @forceUpdate.bind(@, null)
18
18
 
19
19
  render: ->
20
20
  console.log 'render cards', @props.cards, @state
@@ -1,10 +1,11 @@
1
1
  # @cjsx React.DOM
2
+ $ = require('jquery')
2
3
  React = require('react')
3
4
  List = require('./list')
4
5
  CardCollection = require('../models/cards')
5
6
  CardModel = require('../models/card')
6
7
  String = require('string')
7
- config = require('../../shared/config.json')
8
+ config = require('../config')
8
9
 
9
10
  module.exports = React.createClass
10
11
  displayName: 'Content'
@@ -24,9 +25,7 @@ module.exports = React.createClass
24
25
  when "list"
25
26
  console.log 'list', @props.router.query
26
27
  cards = new CardCollection()
27
- cards.query = @props.router.query
28
- cards.query.sort = 'title' if !cards.query.sort
29
- cards.query.order = 'asc' if !cards.query.order
28
+ cards.query = $.extend config.default_query, @props.router.query
30
29
  cards.fetching = true
31
30
  cards.fetch success: ()-> cards.fetching = false
32
31
  title = []
@@ -5,7 +5,7 @@ Edit = require('./edit')
5
5
  CardModel = require('../models/card')
6
6
  ModalTrigger = require('react-bootstrap/lib/ModalTrigger')
7
7
  helpers = require('../helpers')
8
- config = require('../../shared/config.json')
8
+ config = require('../config')
9
9
 
10
10
  module.exports = React.createClass
11
11
  displayName: 'Header'
@@ -6,7 +6,7 @@ Cards = require('./cards')
6
6
  CardCollection = require('../models/cards')
7
7
  Pagination = require('./pagination')
8
8
  helpers = require('../helpers')
9
- config = require('../../shared/config')
9
+ config = require('../config')
10
10
 
11
11
  module.exports = React.createClass
12
12
  displayName: 'List'
@@ -44,9 +44,16 @@ module.exports = React.createClass
44
44
  <div className="row">
45
45
  <div className="col-sm-6" style={{padding:"0px"}}>
46
46
  <ul className="nav nav-pills">
47
- <li><a onClick={helpers.reload} href={"#/?" + @atozParam()} style={{padding:'6px 12px',fontWeight: if @props.cards.query.sort == 'title' and @props.cards.query.order != 'random' then 'bold' else 'normal'}}>A to Z</a></li>
48
- <li><a onClick={helpers.reload} href={"#/?" + @latestParam()} style={{padding:'6px 12px',fontWeight: if @props.cards.query.sort == 'updated_at' and @props.cards.query.order != 'random' then 'bold' else 'normal'}}>Latest</a></li>
49
- <li><a onClick={helpers.reload} href={"#/?" + @randomParam()} style={{padding:'6px 12px',fontWeight: if @props.cards.query.order == 'random' then 'bold' else 'normal'}}>Random</a></li>
47
+ {
48
+ for menuItem in config.menu_items
49
+ switch menuItem
50
+ when 'atoz'
51
+ <li><a onClick={helpers.reload} href={"#/?" + @atozParam()} style={{padding:'6px 12px',fontWeight: if @props.cards.query.sort == 'title' and @props.cards.query.order != 'random' then 'bold' else 'normal'}}>A to Z</a></li>
52
+ when 'latest'
53
+ <li><a onClick={helpers.reload} href={"#/?" + @latestParam()} style={{padding:'6px 12px',fontWeight: if @props.cards.query.sort == 'updated_at' and @props.cards.query.order != 'random' then 'bold' else 'normal'}}>Latest</a></li>
54
+ when 'random'
55
+ <li><a onClick={helpers.reload} href={"#/?" + @randomParam()} style={{padding:'6px 12px',fontWeight: if @props.cards.query.order == 'random' then 'bold' else 'normal'}}>Random</a></li>
56
+ }
50
57
  <li><a href={config.api_path + "/api/cards.xml?" + @queryParam({}, [])} style={{padding:'6px 12px'}}><i className="fa fa-rss" /></a></li>
51
58
  </ul>
52
59
  </div>
@@ -76,7 +83,7 @@ module.exports = React.createClass
76
83
  <div className="row">
77
84
  <div className="col-sm-12" style={{padding:"0px"}}>
78
85
  <ul className="nav nav-pills">
79
- <li><a href={"#/" + @props.card.get('title')} style={fontWeight:'bold'}>{@props.card.get('title')}</a></li>
86
+ <li><a href={"#/" + @props.card.get('title')} style={padding:'6px 12px',fontWeight:'bold'}>{@props.card.get('title')}</a></li>
80
87
  </ul>
81
88
  </div>
82
89
  </div>
@@ -18,10 +18,16 @@ module Carte
18
18
  set :protection, :except => :path_traversal
19
19
  set :views, File.join(File.dirname(__FILE__), 'server/views')
20
20
  set :public_folder, 'public'
21
+ set :default, JSON.parse(File.read(File.join(File.dirname(__FILE__), 'shared/default.json')))
22
+ set :carte, {}
21
23
  set :script_path, '/app.js'
22
24
  end
23
25
 
24
26
  helpers do
27
+ def config
28
+ @config ||= settings.default.update(settings.carte)
29
+ end
30
+
25
31
  def json_data
26
32
  request.body.rewind
27
33
  JSON.parse(request.body.read)
@@ -2,6 +2,6 @@ require 'sinatra/base'
2
2
 
3
3
  module Carte
4
4
  class Server < Sinatra::Base
5
- VERSION = "0.0.12"
5
+ VERSION = "0.0.13"
6
6
  end
7
7
  end
@@ -2,8 +2,8 @@ xml.instruct! :xml, version: '1.0'
2
2
  xml.rss version: "2.0", :"xmlns:atom" => "http://www.w3.org/2005/Atom" do
3
3
  xml.channel do
4
4
  xml.tag! "atom:link", href: "http://#{request.host}/api/cards.xml?#{request.env['QUERY_STRING']}", rel: "self", type: "application/rss+xml"
5
- xml.title settings.carte['title']
6
- xml.description settings.carte['description']
5
+ xml.title config['title']
6
+ xml.description config['description']
7
7
  xml.link "http://#{request.host}/"
8
8
  @cards.each do |card|
9
9
  xml.item do
@@ -2,9 +2,9 @@
2
2
  %html
3
3
  %head
4
4
  %meta{charset:"utf-8"}
5
- %title= settings.carte['title']
5
+ %title= config['title']
6
6
  %meta{name:"viewport",content:"width=device-width,initial-scale=1.0"}
7
- %meta{name:"description",content:settings.carte['description']}
7
+ %meta{name:"description",content:config['description']}
8
8
  %script{type:"text/javascript",src:"/app.js"}
9
9
  :css
10
10
  .navbar-default a,
@@ -24,7 +24,7 @@
24
24
  text-decoration: none !important;
25
25
  }
26
26
  a, a:hover, a:visited, a:active {
27
- color: #{settings.carte['link_color']};
27
+ color: #{config['link_color']};
28
28
  }
29
29
  .glyphicon-refresh-animate {
30
30
  -animation: spin .7s infinite linear;
@@ -1,32 +1,14 @@
1
1
  {
2
2
  "title": "Carte Sandbox",
3
3
  "description": "Sandbox for Carte",
4
- "views": {
5
- "menu": [],
6
- "query": {}
7
- },
8
- "models": {
9
- "card": {
10
- "validations": {
11
- "title": {
12
- "presence": true,
13
- "length": 70
14
- },
15
- "description": {
16
- "presence": true,
17
- "length": {
18
- "maximum": 70
19
- }
20
- },
21
- "tags": {
22
- "length": 3,
23
- "array": {
24
- "length": {
25
- "maximum": 10
26
- }
27
- }
28
- }
29
- }
30
- }
31
- }
4
+ "public_folder": "public",
5
+ "script_path": "public/app.js",
6
+ "link_color": "yellow",
7
+ "api_path": "",
8
+ "menu_items": ["atoz", "latest", "random"],
9
+ "default_query": {"sort": "title", "order": "asc"},
10
+ "title_max_length": 70,
11
+ "description_max_length": 560,
12
+ "tags_max_size": 3,
13
+ "tag_max_length": 10
32
14
  }
@@ -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.12",
4
+ "version": "0.0.13",
5
5
  "main": "lib/carte.coffee",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carte-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - tily
@@ -226,6 +226,7 @@ files:
226
226
  - lib/carte.coffee
227
227
  - lib/carte.rb
228
228
  - lib/carte/client.coffee
229
+ - lib/carte/client/config.coffee
229
230
  - lib/carte/client/helpers.coffee
230
231
  - lib/carte/client/models/card.coffee
231
232
  - lib/carte/client/models/cards.coffee