Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions client/collection_view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ get_filter_query = (collection) ->
resubscribe = (name) ->
# Stop the old subscription and resubscribe with the new filter/sort
subscription_name = "_houston_#{name}"
Houston._paginated_subscription.stop()
Houston._paginated_subscription?.stop()
Houston._paginated_subscription =
Meteor.subscribeWithPagination subscription_name,
get_sort_by(), get_filter_query(Houston._get_collection(name)),
Expand All @@ -48,17 +48,17 @@ Template._houston_collection_view.helpers
num_of_records: -> collection_count(@name) or "no"
pluralize: -> 's' unless collection_count(@name) == 1
rows: ->
collection = @name
documents = this?.find(get_filter_query(Houston._get_collection(collection)), {sort: get_sort_by()}).fetch()
_.map documents, (d) ->
d.collection = collection
collection = Houston._get_collection(@name)
documents = collection?.find(get_filter_query(collection), {sort: get_sort_by()}).fetch()
_.map documents, (d) =>
d.collection = @name
d._id = d._id._str or d._id
return d
values_in_order: ->
fields_in_order = get_collection_view_fields(@collection)
names_in_order = _.clone fields_in_order
values = (Houston._nested_field_lookup(@, field.name) for field in fields_in_order[1..]) # skip _id
({field_value: field_value.toString(), field_name, collection: @collection} for [field_value, {name:field_name}] in _.zip values, names_in_order[1..])
({field_value: field_value.toString(), field_name, @collection} for [field_value, {name: field_name}] in _.zip values, names_in_order[1..])
filter_value: ->
if Houston._session('field_selectors') and Houston._session('field_selectors')[@]
Houston._session('field_selectors')[@]
Expand Down
2 changes: 1 addition & 1 deletion client/collection_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ <h4>
<tbody>
{{#each rows }}
<tr id="ID_{{sort_order}}" data-id="{{_id}}">
<td><a href="{{pathFor 'houston_document'}}"><i
<td><a href="{{pathFor 'houston_document' collection=collection _id=_id}}"><i
class="fa fa-file"></i>{{_id}}</a></td>
{{#each values_in_order}}
<td data-field='{{ field_name }}' class='houston-collection-field'>
Expand Down
8 changes: 6 additions & 2 deletions client/db_view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ filterCollections = (query, collections) ->
else
collections


Template._houston_db_view.helpers
collections: -> @collections
collections: -> Houston._collections.collections
filtered_collections: ->
filterCollections(Houston._session('search'), @collections.find().fetch())
filterCollections(
Houston._session('search'),
Houston._collections.collections.find().fetch()
)

Template._houston_db_view.events
# trigger meteor session invalidation, definitely a hack
Expand Down
3 changes: 2 additions & 1 deletion client/document_view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ Template._houston_document_view.events
'click #houston-save': (e) ->
e.preventDefault()
update_dict = {}
collection = Houston._get_collection(@name)
for field in $('.houston-field')
field_name = field.name.split(' ')[0]
unless field_name is '_id'
update_dict[field_name] = Houston._convert_to_correct_type(field_name, field.value, @collection)
update_dict[field_name] = Houston._convert_to_correct_type(field_name, field.value, collection)
Houston._call("#{@name}_update", @document._id, $set: update_dict, Houston._show_flash)

'click #houston-delete': (e) ->
Expand Down
3 changes: 2 additions & 1 deletion client/master_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
{{> _houston_sidenav}}
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
{{> yield}}
{{> Template.dynamic template=template data=data}}

{{> _houston_flash_message }}
</div>
</div>
Expand Down
52 changes: 30 additions & 22 deletions client/router.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Houston._houstonize_route = (name) ->
Houston._houstonize(name)[1..]

Houston._go = (route_name, options) ->
Router.go Houston._houstonize_route(route_name), options
FlowRouter.go Houston._houstonize_route(route_name), options


houston_route = (route_name, options) =>
Expand All @@ -37,12 +37,16 @@ houston_route = (route_name, options) =>
subscriptions = if options.subs then options.subs(this.params) else []
subscriptions.push Houston._subscribe('admin_user')
subscriptions
Router.route "#{Houston._ROOT_ROUTE}#{options.houston_path}", options
options.action = (params) ->
# keep iron-router style this.params working via .call
data = options.data?.call({params})
BlazeLayout.render options.layoutTemplate,
{template: options.template, data}
FlowRouter.route "#{Houston._ROOT_ROUTE}#{options.houston_path}", options

houston_route 'home',
houston_path: '/'
template: 'db_view'
data: -> collections: Houston._collections.collections
waitOn: -> Houston._collections

houston_route 'login',
Expand All @@ -60,7 +64,7 @@ houston_route 'custom_template',

houston_route 'collection',
houston_path: "/:collection_name"
data: -> Houston._get_collection(@params.collection_name)
data: -> {name: @params.collection_name}
subs: (params) -> [setup_collection(params.collection_name)]
template: 'collection_view'

Expand All @@ -70,7 +74,7 @@ houston_route 'document',
@subscription = setup_collection(@params.collection, @params._id)
collection = Houston._get_collection(@params.collection)
document = collection.findOne _id: @params._id
{document, collection, name: @params.collection}
{document, name: @params.collection}
template: 'document_view'

# ########
Expand All @@ -79,34 +83,38 @@ houston_route 'document',
mustBeAdmin = ->
if !Meteor.user()
if Meteor.loggingIn()
@render 'houstonLoading'
console.log "logging in, TODO(AMK) do a nice job"
else
Houston._go 'login'
else
if @ready() and not Houston._user_is_admin Meteor.userId()
console.log "should check if ready I guess... TODO(AMK) "
if not Houston._user_is_admin Meteor.userId()
Houston._go 'login'
else
@next()

# If the host app doesn't have a router, their html may show up
hide_non_admin_stuff = ->
$('body').css('visibility', 'hidden').children().hide()
$('body>.houston').show()
@next()
remove_host_css = ->
$('link[rel="stylesheet"]').remove()
@next()

BASE_HOUSTON_ROUTES = (Houston._houstonize_route(name) for name in ['home', 'collection', 'document', 'change_password', 'custom_template'])
ALL_HOUSTON_ROUTES = BASE_HOUSTON_ROUTES.concat([Houston._houstonize_route('login')])
Router.onBeforeAction mustBeAdmin, only: BASE_HOUSTON_ROUTES
Router.onBeforeAction hide_non_admin_stuff, only: ALL_HOUSTON_ROUTES
Router.onBeforeAction remove_host_css, only: ALL_HOUSTON_ROUTES

onRouteNotFound = Router.onRouteNotFound
Router.onRouteNotFound = (args...) ->
non_houston_routes = _.filter(Router.routes, (route) -> route.name.indexOf('houston_') != 0)
if non_houston_routes.length > 0
onRouteNotFound.apply Router, args
else
console.log "Note: Houston is suppressing Iron-Router errors because we don't think you are using it."
FlowRouter.triggers.enter([mustBeAdmin], only: BASE_HOUSTON_ROUTES)
FlowRouter.triggers.enter(
[hide_non_admin_stuff, remove_host_css],
only: ALL_HOUSTON_ROUTES)

Template.registerHelper 'pathFor', (route, args) ->
FlowRouter.path(route, args.hash)

originalNotFound = FlowRouter.notFound
FlowRouter.notFound =
action: (args...) ->
non_houston_routes = _.filter(
FlowRouter._routes,
(route) -> route.name? and route.name.indexOf('houston_') != 0)
if non_houston_routes.length > 0
originalNotFound.action(args...)
else
console.log "Note: Houston is suppressing Iron-Router errors because we don't think you are using it."
5 changes: 4 additions & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ Package.on_use(function(api) {
//////////////////////////////////////////////////////////////////
// Third-party package dependencies
//////////////////////////////////////////////////////////////////
api.use('iron:router@1.0.1', 'client');

api.use('kadira:flow-router@2.8.0', 'client');
api.use('kadira:blaze-layout@2.2.0', 'client');

api.use('tmeasday:paginated-subscription@0.2.4', 'client');
api.use('dburles:mongo-collection-instances@0.3.4', ['client', 'server']);

Expand Down
12 changes: 12 additions & 0 deletions test/route-test-app/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.

notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes
1 change: 1 addition & 0 deletions test/route-test-app/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
7 changes: 7 additions & 0 deletions test/route-test-app/.meteor/.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics

1wiz6wtybu4fj1vmrr8m
23 changes: 23 additions & 0 deletions test/route-test-app/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base # Packages every Meteor app needs to have
mobile-experience # Packages for a great mobile UX
mongo # The database Meteor supports right now
blaze-html-templates # Compile .html files into Meteor Blaze views
session # Client-side reactive dictionary for your app
jquery # Helpful client-side library
tracker # Meteor's client-side reactive programming library

standard-minifiers # JS/CSS minifiers run for production mode
es5-shim # ECMAScript 5 compatibility for older browsers.
ecmascript # Enable ECMAScript2015+ syntax in app code

autopublish # Publish all data to the clients (for prototyping)
insecure # Allow all DB writes from clients (for prototyping)
kadira:flow-router
kadira:blaze-layout
houston:admin
2 changes: 2 additions & 0 deletions test/route-test-app/.meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
browser
1 change: 1 addition & 0 deletions test/route-test-app/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
METEOR@1.2.1
84 changes: 84 additions & 0 deletions test/route-test-app/.meteor/versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
accounts-base@1.2.2
accounts-password@1.1.4
autopublish@1.0.4
autoupdate@1.2.4
babel-compiler@5.8.24_1
babel-runtime@0.1.4
base64@1.0.4
binary-heap@1.0.4
blaze@2.1.3
blaze-html-templates@1.0.1
blaze-tools@1.0.4
boilerplate-generator@1.0.4
caching-compiler@1.0.0
caching-html-compiler@1.0.2
callback-hook@1.0.4
check@1.1.0
coffeescript@1.0.11
cosmos:browserify@0.5.1
dburles:mongo-collection-instances@0.3.4
ddp@1.2.2
ddp-client@1.2.1
ddp-common@1.2.2
ddp-rate-limiter@1.0.0
ddp-server@1.2.2
deps@1.0.9
diff-sequence@1.0.1
ecmascript@0.1.6
ecmascript-runtime@0.2.6
ejson@1.0.7
email@1.0.8
es5-shim@4.1.14
fastclick@1.0.7
geojson-utils@1.0.4
hot-code-push@1.0.0
houston:admin@2.0.6
html-tools@1.0.5
htmljs@1.0.5
http@1.1.1
id-map@1.0.4
insecure@1.0.4
jquery@1.11.4
kadira:blaze-layout@2.2.0
kadira:flow-router@2.8.0
lai:collection-extensions@0.1.4
launch-screen@1.0.4
livedata@1.0.15
localstorage@1.0.5
logging@1.0.8
meteor@1.1.10
meteor-base@1.0.1
minifiers@1.1.7
minimongo@1.0.10
mobile-experience@1.0.1
mobile-status-bar@1.0.6
mongo@1.1.3
mongo-id@1.0.1
npm-bcrypt@0.7.8_2
npm-mongo@1.4.39_1
observe-sequence@1.0.7
ordered-dict@1.0.4
promise@0.5.1
random@1.0.5
rate-limit@1.0.0
reactive-dict@1.1.3
reactive-var@1.0.6
reload@1.1.4
retry@1.0.4
routepolicy@1.0.6
service-configuration@1.0.5
session@1.1.1
sha@1.0.4
spacebars@1.0.7
spacebars-compiler@1.0.7
srp@1.0.4
standard-minifiers@1.0.2
templating@1.1.5
templating-tools@1.0.0
tmeasday:paginated-subscription@0.2.4
tracker@1.0.9
ui@1.0.8
underscore@1.0.4
url@1.0.5
webapp@1.2.3
webapp-hashing@1.0.5
1 change: 1 addition & 0 deletions test/route-test-app/packages/houston:admin
1 change: 1 addition & 0 deletions test/route-test-app/route-test-app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* CSS declarations go here */
9 changes: 9 additions & 0 deletions test/route-test-app/route-test-app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template name="hello">
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>

<template name="mainLayout">
ohi
{{> Template.dynamic template=content}}
</template>
Loading