carte-server 0.0.11 → 0.0.12

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: 81e563d2f145372384e814a906391a8dcbfd9c90
4
- data.tar.gz: e32d135bfd79cae9602708a24cee742bb83cf046
3
+ metadata.gz: ba996bbb2d71cf1b95ae1955737496ffe9b2a27a
4
+ data.tar.gz: 19aa30df9a3807971d76e5a7a256eca9fb554228
5
5
  SHA512:
6
- metadata.gz: d0ab2c1163049dda3b0eed605b56ce8ac010ac8dfef5e490c9e284814b59377390882c2512bc82954395d59c39ff77c2cae21ad334e6ef1e2ec688d0a0d8e959
7
- data.tar.gz: 7e54aab85fbaa0958e7430ae93f271c63b36d9a2862d12158d6084ca5fbd8b9d13be68fe1213bf3dfdd1ad4f7d8180119095675b9751f156306752f3dd0885c9
6
+ metadata.gz: c12da1320c1311ae74b500d6de2e1ff903adc5aeb7b90a87ca2e05881b15a03c4bef831b07c8c1edfb419dc6ac78321ab2923e657964feb8137af3a10e56c284
7
+ data.tar.gz: ae179b634d6bf222611497408d54fe21e31255fba216ca8810db75a26b4961ffed8560b205f9ffff512b81e27b7deb78f07b2198d623524459064566af672ddd
@@ -4,15 +4,5 @@
4
4
  "public_folder": "public",
5
5
  "script_path": "public/app.js",
6
6
  "link_color": "yellow",
7
- "api_path": "",
8
- "models": {
9
- "card": {
10
- "title": {
11
- "length": {"maximum": "170"}
12
- },
13
- "description": {
14
- "length": {"maximum": "170"}
15
- }
16
- }
17
- }
7
+ "api_path": ""
18
8
  }
@@ -1,17 +1,3 @@
1
1
  gulp = require 'gulp'
2
2
  Carte = require './lib/carte'
3
-
4
- carte = new Carte()
5
- path = 'public/app.js'
6
-
7
- gulp.task 'build', ->
8
- carte.build
9
- watch: false
10
- minify: true
11
- config: __dirname + '/config.json'
12
-
13
- gulp.task 'watch', ->
14
- carte.build
15
- watch: true
16
- minifty: false
17
- config: __dirname + '/config.json'
3
+ new Carte().install(gulp, __dirname + '/config.json')
@@ -10,6 +10,18 @@ uglify = require 'gulp-uglify'
10
10
  streamify = require 'gulp-streamify'
11
11
 
12
12
  module.exports = class Carte
13
+ install: (gulp, config)->
14
+ gulp.task 'build', =>
15
+ @build
16
+ watch: false
17
+ minify: true
18
+ config: config
19
+ gulp.task 'watch', =>
20
+ @build
21
+ watch: true
22
+ minifty: false
23
+ config: config
24
+
13
25
  build: (options)->
14
26
  config = require(options.config)
15
27
  fs.writeFileSync(__dirname + '/carte/shared/config.json', JSON.stringify(config))
@@ -13,15 +13,6 @@ module.exports = class Router extends Backbone.Router
13
13
  @query = querystring.parse(string)
14
14
  console.log @query
15
15
 
16
- new: ()->
17
- console.log 'new'
18
- @current = 'new'
19
-
20
- edit: (title)->
21
- console.log 'edit', title
22
- @current = 'edit'
23
- @title = title
24
-
25
16
  show: (title)->
26
17
  console.log 'show', title
27
18
  @current = 'show'
@@ -14,7 +14,7 @@ module.exports = React.createClass
14
14
  render: ->
15
15
  Button = require('react-bootstrap/lib/Button')
16
16
  <div>
17
- <Header key='header' />
17
+ <Header key='header' router={@props.router} />
18
18
  <Content key='content' router={@props.router} />
19
19
  <Footer key='footer' />
20
20
  </div>
@@ -5,30 +5,36 @@ Card = require('./card')
5
5
  module.exports = React.createClass
6
6
  displayName: 'Cards'
7
7
 
8
+ getInitialState: ()->
9
+ error: false
10
+
8
11
  componentDidMount: ()->
9
12
  console.log 'component did mount'
10
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)
11
18
 
12
19
  render: ->
13
- console.log 'render cards', @props.cards
14
- if !@props.cards.fetching
15
- console.log 'cards loaded'
16
- cards = @props.cards.map (card)-> <Card key={card.get("title")} card={card} />
17
- <div className='row'>{cards}</div>
18
- else if @props.cards.error
20
+ console.log 'render cards', @props.cards, @state
21
+ if @state.error
19
22
  <div className='row'>
20
23
  {
21
24
  for i in [1..9]
22
25
  <div className='col-sm-4' style={padding:'5px'} onMouseOver={@onMouseOver} onMouseLeave={@onMouseLeave}>
23
26
  <div className='list-group'style={margin:'0px',padding:'0px'}>
24
27
  <div className='list-group-item' style={height:'220px'}>
25
- <i className='glyphicon glyphicon-alert' />
26
- {@props.cards.error}
28
+ <i className='glyphicon glyphicon-alert' /> {@state.error.status} {@state.error.statusText}
27
29
  </div>
28
30
  </div>
29
31
  </div>
30
32
  }
31
33
  </div>
34
+ else if !@props.cards.fetching
35
+ console.log 'cards loaded'
36
+ cards = @props.cards.map (card)-> <Card key={card.get("title")} card={card} />
37
+ <div className='row'>{cards}</div>
32
38
  else
33
39
  console.log 'cards loading'
34
40
  <div className='row'>
@@ -37,7 +37,7 @@ module.exports = React.createClass
37
37
  title = 'search: ' + cards.query.title + ' (' + title + ')' if cards.query.title
38
38
  title += ' - ' + config.title
39
39
  document.title = title
40
- <List key='list' router={@props.router} cards={cards} showNav=true />
40
+ <List key='list' router={@props.router} cards={cards} />
41
41
  when "show"
42
42
  console.log 'show'
43
43
  cards = new CardCollection()
@@ -60,7 +60,8 @@ module.exports = React.createClass
60
60
  cards.add cardModel
61
61
  cards.fetching = false
62
62
  error: (card, response)=>
63
- console.log response
63
+ console.log 'error!!!!!!!!!!!!!!!!!!!!!!!!', response
64
+ cards.fetching = false
64
65
  document.title = card.get('title') + ' - ' + config.title
65
66
  <List key='show' cards={cards} card={card} />
66
67
  else
@@ -15,13 +15,29 @@ module.exports = React.createClass
15
15
 
16
16
  componentWillMount: ()->
17
17
  console.log 'header mounted'
18
- @card = new CardModel()
19
- @card._isNew = true
20
- @card.on 'sync', (model)=>
21
- console.log 'sync!!!'
18
+ @onSync = ()=>
19
+ console.log 'model new calback'
22
20
  @card = new CardModel()
23
21
  @card._isNew = true
22
+ @card.on 'sync', @onSync
24
23
  @forceUpdate()
24
+ @onSync()
25
+
26
+ @callback = ()=>
27
+ if @props.router.query
28
+ searchText = []
29
+ if @props.router.query.tags
30
+ for tag in @props.router.query.tags.split(',')
31
+ searchText.push '#' + tag
32
+ if @props.router.query.title
33
+ searchText.push @props.router.query.title
34
+ @setState searchText: searchText.join(' ')
35
+ @forceUpdate()
36
+ @props.router.on "route", @callback
37
+
38
+ componentWillUnmount: ->
39
+ console.log 'componentWillMount un'
40
+ @props.router.off "route", @callback
25
41
 
26
42
  onChangeSearchText: ()->
27
43
  @setState searchText: event.target.value
@@ -30,7 +46,16 @@ module.exports = React.createClass
30
46
  if event.keyCode == 13 # ENTER
31
47
  console.log '13 enter'
32
48
  event.preventDefault()
33
- query = {title: @state.searchText}
49
+ tags = []
50
+ titles = []
51
+ for searchText in @state.searchText.split(' ')
52
+ if match = searchText.match(/^#(.+)/)
53
+ tags.push(match[1])
54
+ else
55
+ titles.push(searchText)
56
+ query = {}
57
+ query.title = titles.join(' ') if titles.length > 0
58
+ query.tags = tags.join(',') if tags.length > 0
34
59
  location.hash = '/?' + $.param(query)
35
60
 
36
61
  render: ->
@@ -48,11 +48,6 @@ module.exports = React.createClass
48
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
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>
50
50
  <li><a href={config.api_path + "/api/cards.xml?" + @queryParam({}, [])} style={{padding:'6px 12px'}}><i className="fa fa-rss" /></a></li>
51
- {
52
- if @props.cards.query.tags
53
- @props.cards.query.tags.split(',').map (tag)=>
54
- <li><a href={"#/?" + @tagParam(tag)} style={padding:'6px 12px'}><i className="glyphicon glyphicon-tag" />&nbsp;{tag}</a></li>
55
- }
56
51
  </ul>
57
52
  </div>
58
53
  <div className="col-sm-6" style={{padding:"0px"}}>
@@ -86,7 +81,7 @@ module.exports = React.createClass
86
81
  </div>
87
82
  </div>
88
83
  }
89
- <Cards cards={@props.cards} />
84
+ <Cards cards={@props.cards} card={@props.card} />
90
85
  {
91
86
  if !@props.card && helpers.isMobile()
92
87
  <div className="row">
@@ -2,6 +2,6 @@ require 'sinatra/base'
2
2
 
3
3
  module Carte
4
4
  class Server < Sinatra::Base
5
- VERSION = "0.0.11"
5
+ VERSION = "0.0.12"
6
6
  end
7
7
  end
@@ -0,0 +1,32 @@
1
+ {
2
+ "title": "Carte Sandbox",
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
+ }
32
+ }
@@ -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.11",
4
+ "version": "0.0.12",
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.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - tily
@@ -250,6 +250,7 @@ files:
250
250
  - lib/carte/server/views/cards.builder
251
251
  - lib/carte/server/views/index.haml
252
252
  - lib/carte/shared/.keep
253
+ - lib/carte/shared/default.json
253
254
  - mongoid.yml
254
255
  - package.json
255
256
  - public/images/icon.png