Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
70f1511
Elasticsearch WIP
davidkaneda Aug 11, 2014
a6b9dca
Add elasticsearch to Travis
davidkaneda Aug 11, 2014
44c7bbb
Remove entry via doc so middleware is called
davidkaneda Aug 13, 2014
f85aebb
Try waiting for a the indexed callback before running test
davidkaneda Aug 13, 2014
f723f7d
Merge branch 'master' into basic-search
davidkaneda Aug 13, 2014
e43f070
Set custom timeout for Search test 'before'
davidkaneda Aug 13, 2014
815a341
Nix the synchronize call
davidkaneda Aug 13, 2014
8f6e6b1
Try a timeout on Entry remove
davidkaneda Aug 16, 2014
88b891e
Oi
davidkaneda Aug 16, 2014
40d54c9
Last try
davidkaneda Aug 16, 2014
4ee36ed
Fix User roles test
davidkaneda Aug 16, 2014
6b135e4
Fix for Bucket#remove -> Entry#remove callback
davidkaneda Aug 16, 2014
f3ea731
Force rebuild
davidkaneda Aug 16, 2014
20f25f4
Move mongoosastic to production deps
davidkaneda Aug 16, 2014
cd25859
Add Bonsai support, change config format
davidkaneda Aug 16, 2014
e7204b1
More fixees for tests
davidkaneda Aug 16, 2014
8544c4e
Update mongoosastic
davidkaneda Aug 16, 2014
d8ca5ec
Abstract 'rest' function for tests
davidkaneda Aug 17, 2014
5728901
Merge branch 'master' into basic-search
davidkaneda Aug 17, 2014
86636c1
Add search to the frontend
davidkaneda Aug 17, 2014
86b2b90
Separate DB and ES resets
davidkaneda Aug 17, 2014
1bd7e8c
Upgrade mongoosastic
davidkaneda Aug 18, 2014
7e48aad
Merge branch 'master' into basic-search
davidkaneda Aug 24, 2014
9631e62
Fix for migration
davidkaneda Aug 24, 2014
8c526d0
Raising the timeout to be safe
davidkaneda Aug 24, 2014
fc2a5ae
Raise the timeout for the #findByParams test
davidkaneda Aug 24, 2014
db2aa1c
Adds Bucket negation via #findByParams
davidkaneda Aug 24, 2014
7f3f3b0
Merge branch 'master' into basic-search
davidkaneda Aug 24, 2014
b113a23
Merge branch 'master' into basic-search
davidkaneda Aug 24, 2014
8259cda
Fix install, was overzealous with _id updates
davidkaneda Aug 24, 2014
cda4c86
Express 4 syntax updates
davidkaneda Aug 24, 2014
10b3a23
Switch bonsai to searchbox
davidkaneda Aug 24, 2014
77b1e6a
Merge branch 'master' into search
davidkaneda Aug 25, 2014
6a9aad0
Fix for search redirects
davidkaneda Aug 25, 2014
697765f
Merge branch 'master' into search
davidkaneda Aug 30, 2014
52024fb
Merge branch 'npm-module' into search
davidkaneda Aug 30, 2014
dfe5a84
Merge branch 'master' of https://github.com/asm-products/buckets into…
davidkaneda Aug 31, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: node_js

services: mongodb
services:
- mongodb
- elasticsearch

before_install:
- npm install -g grunt-cli
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"BUILDPACK_URL": "https://github.com/mbuchetics/heroku-buildpack-nodejs-grunt.git",
"NODE_ENV": "production"
},
"addons": ["mongohq", "mandrill"]
"addons": ["mongohq", "mandrill", "searchbox"]
}
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"fastclick": "~1.0.2",
"gsap": "~1.13.1",
"seedrandom": "~2.3.6",
"Sortable": "~0.3.0"
"Sortable": "~0.3.0",
"typeahead.js": "~0.10.5"
},
"exportsOverride": {
"jquery.formParams": {
Expand Down
2 changes: 1 addition & 1 deletion client/source/controllers/buckets_controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = class BucketsController extends Controller
compose: (options) ->
@entries = new Entries

@entries.fetch( data: {bucket: bucket.get('slug'), status: ''}, processData: yes ).done =>
@entries.fetchWithParams( bucket: bucket.get('slug'), status: '' ).done =>
@view = new EntriesBrowser
collection: @entries
bucket: bucket
Expand Down
2 changes: 1 addition & 1 deletion client/source/helpers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Handlebars.registerHelper 'timeAgo', (dateTime) ->
expanded = Handlebars.helpers.simpleDateTime dateTime

new Handlebars.SafeString """
<span title="#{expanded}" class="show-tooltip">
<span title="#{expanded}" class="show-tooltip" data-placement="right">
#{moment(dateTime).fromNow()}
</span>
"""
Expand Down
3 changes: 3 additions & 0 deletions client/source/models/entries.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ module.exports = class Entries extends Collection
@url += "?#{$.param(bucketId: bucketId)}"
@fetch()

fetchWithParams: (params={}) ->
@fetch({data: params}, processData: yes)

comparator: (entry) ->
- new Date(entry.get('publishDate')).getTime()
3 changes: 3 additions & 0 deletions client/source/templates/buckets/dashboard.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
<div class="row">
<div class="col-md-6">
<p class="lead">Buckets is an open-source CMS, built in Node.js, which is being actively developed by <a href="https://assembly.com/buckets" target="_blank">the community at Assembly</a>.</p>

<input type="search" name="search" class="form-control input-lg" placeholder="Search">

</div>
</div>
1 change: 1 addition & 0 deletions client/source/templates/entries/suggestion.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span class="color-{{bucket.color}}">{{icon bucket.icon}}</span> <strong>{{title}}</strong> <br><span class="text-muted">{{timeAgo publishDate}}</span>
42 changes: 42 additions & 0 deletions client/source/views/buckets/dashboard.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
_ = require 'underscore'
Chaplin = require 'chaplin'
PageView = require 'views/base/page'

mediator = require 'mediator'

suggestionTpl = require 'templates/entries/suggestion'
tpl = require 'templates/buckets/dashboard'

module.exports = class DashboardView extends PageView
template: tpl

events:
'typeahead:selected': 'selectItem'

render: ->
super

engine = new Bloodhound
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value')
queryTokenizer: Bloodhound.tokenizers.whitespace
prefetch: '/api/entries'
remote: '/api/entries/?query=%QUERY*'

engine.initialize()
engine.clearRemoteCache();

@$search = @$('[name="search"]').typeahead
highlight: yes
,
name: 'entries',
displayKey: 'title'
templates: {
empty: """
<div class="tt-empty text-muted">
No matching entries.
</div>
"""
suggestion: suggestionTpl
}
source: engine.ttAdapter()

_.defer => @$search.focus()

selectItem: (e, item) ->
Chaplin.utils.redirectTo 'buckets#browse',
slug: item.bucket.slug
entryID: item.id
45 changes: 43 additions & 2 deletions client/style/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ $sans = 'Avenir Next', Avenir, 'Helvetica Neue', Helvetica, 'Segoe UI', Segoe, R

body
background-color #fcfcfc
display table
width 100%
overflow-x hidden
display flex
min-height 100vh
flex-direction column

#bkts-content
Expand Down Expand Up @@ -157,3 +156,45 @@ input[type="text"].form-control, textarea.form-control
.pageBreadcrumb
margin 10px 0
background-color #f1f1f1


.tt-query
width 300px
outline none

.tt-hint
color: #999

.tt-highlight
background-color rgba(lighten($yellow, 30), .5)

.tt-dropdown-menu
margin-top 12px
padding 2px 0
background-color #fff
border 1px solid #ccc
border 1px solid rgba(0, 0, 0, 0.2)
border-radius 2px
width 100%
color #555

.icon
vertical-align middle
display inline-block
font-size 24px

.tt-suggestion
padding: 3px 20px
font-size: 18px
line-height: 24px

.tt-suggestion.tt-cursor
color #222
background-color lighten($primary, 30)
cursor pointer

.tt-suggestion p
margin: 0

.tt-empty
padding: 3px 20px
27 changes: 27 additions & 0 deletions migrations/20140810052927866_sync_with_es.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Bucket = require '../server/models/bucket'
Entry = require '../server/models/entry'

http = require 'http'
config = require '../server/config'

module.exports =
requiresDowntime: no # true or false

up: (done) ->
Entry.update {content: null}, {content: {}}, {multi: yes}, (e, entries) ->
throw e if e

Entry.createMapping (err) ->
throw e if e
stream = Entry.synchronize()
count = 0

stream.on 'data', (e, doc) -> count++
stream.on 'close', ->
console.log('Indexed ' + count + ' entries into ElasticSearch')
done()

stream.on 'error', (e) -> throw e

down: (done) ->
done()
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"author": "David Kaneda <dk@morfunk.com> (http://www.davidkaneda.com)",
"license": "AGPL-3.0",
"bugs": {
"url": "https://assemblymade.com/buckets/wips"
"url": "https://assembly.com/buckets/wips"
},
"keywords": [
"cms",
Expand Down Expand Up @@ -78,6 +78,7 @@
"inflection": "^1.3.6",
"marked": "^0.3.2",
"moment": "^2.7.0",
"mongoosastic": "^0.4.0",
"mongoose": "^3.8.15",
"mongoose-regexp": "0.0.1",
"mongoose-unique-validator": "^0.3.0",
Expand Down
3 changes: 3 additions & 0 deletions server/config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ config =
catchAll: yes
autoStart: yes
db: "mongodb://localhost/buckets_#{env}"
elasticsearch:
url: process.env.SEARCHBOX_SSL_URL || 'http://127.0.0.1:9200'
index: "buckets_entries_#{env}"
production:
smtp:
service: 'Mandrill'
Expand Down
28 changes: 22 additions & 6 deletions server/models/bucket.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ db = require '../lib/database'
fieldSchema = new mongoose.Schema
name:
type: String
unique: no
required: yes
slug:
type: String
Expand All @@ -21,8 +20,7 @@ fieldSchema = new mongoose.Schema
required: yes
settings: mongoose.Schema.Types.Mixed

fieldSchema
.path 'slug'
fieldSchema.path 'slug'
.validate (val) ->
val not in [
'title'
Expand Down Expand Up @@ -58,12 +56,30 @@ bucketSchema = new mongoose.Schema
required: yes
icon:
type: String
enum: ['edit', 'photos', 'calendar', 'movie', 'music-note', 'map-pin', 'quote', 'artboard', 'contacts-1']
enum: [
'edit'
'photos'
'calendar'
'movie'
'music-note'
'map-pin'
'quote'
'artboard'
'contacts-1'
]
default: 'edit'
required: yes
color:
type: String
enum: ['teal', 'purple', 'red', 'yellow', 'blue', 'orange', 'green']
enum: [
'teal'
'purple'
'red'
'yellow'
'blue'
'orange'
'green'
]
default: 'teal'
required: yes
urlPattern: String
Expand Down Expand Up @@ -95,7 +111,7 @@ bucketSchema.path('urlPattern').validate (value) ->
bucketSchema.plugin uniqueValidator, message: '“{VALUE}” is already taken.'

bucketSchema.post 'remove', ->
@model('Entry').remove(bucket: @_id).exec()
@model('Entry').find(bucket: @_id).remove().exec()

bucketSchema.methods.getMembers = (callback) ->
@model('User').find
Expand Down
Loading