These are chat archives for canjs/canjs

10th
Mar 2015
Justin Love
@JustinLove
Mar 10 2015 14:54
Are there complex examples of can.route?
Justin Meyer
@justinbmeyer
Mar 10 2015 16:05
@JustinLove https://github.com/bitovi/steal-can-example/blob/master/main.js is a small but complex example
what kind of example are you looking for?
Justin Meyer
@justinbmeyer
Mar 10 2015 16:23
If you were using the #minor branch, it had everything in a "lib" folder. That is now gone in master. So if you were using that structure, you will need to change your paths configuration to point to the new location.
Justin Meyer
@justinbmeyer
Mar 10 2015 16:33
@alexisabril regarding your pushstate question ...
do you need to return the data?
sorry, the html
Alexis Abril
@alexisabril
Mar 10 2015 16:34
nope
just looking to ignore /foo/bar/baz from the node side
Justin Meyer
@justinbmeyer
Mar 10 2015 16:34
Ok, so you just need to handle all incoming urls
Alexis Abril
@alexisabril
Mar 10 2015 16:34
not really canjs specific
Justin Meyer
@justinbmeyer
Mar 10 2015 16:34
oh, but not sure how to do it?
Alexis Abril
@alexisabril
Mar 10 2015 16:34
yep, totally lazyweb
app.use('/', serveStatic(__dirname))
.use(function(req, res) {});
Justin Meyer
@justinbmeyer
Mar 10 2015 16:35
what framework?
express
Alexis Abril
@alexisabril
Mar 10 2015 16:35
connect; that noop needs a res.end(), however calling end will actually overwrite the existing html
Justin Meyer
@justinbmeyer
Mar 10 2015 16:36
calling end?
oh, res.end
it actually writes the existing html?
oh, b/c you are serving static
Alexis Abril
@alexisabril
Mar 10 2015 16:43
the static section is irrelevant for this case actually; one possible solution is to redirect all incoming requests to a specified index.html or redirect to a #! + request path
Curtis Cummings
@ccummings
Mar 10 2015 17:07
There's a third param to a middleware function called next. Call that at the end of handling your route instead end to let the next middleware take over
instead of*
Alexis Abril
@alexisabril
Mar 10 2015 17:07
true, however that'll eventually timeout since no response is returned
Matthew Phillips
@matthewp
Mar 10 2015 17:46
@justinbmeyer should package.json main point to dist/cjs/can.js?
"browser" doesn't handle the main does it?
Curtis Cummings
@ccummings
Mar 10 2015 17:55
Is it possible to get a 2.2.0-pre published to npm? I'm interested in seeing what the npm release will look like in a Browserify environment. Will I still need a ton of browser mappings to require things like can/construct/proxy
Matthew Phillips
@matthewp
Mar 10 2015 17:56
:+1: i want the same thing
Justin Meyer
@justinbmeyer
Mar 10 2015 17:58
@ccummings you wont
you won't need any browser mappings
if you are using the latest browserify
they are in canjs's package
@daffl can we get a 2.2.0-alpha.11
@ccummings alpha.10 should work alright too
Matthew Phillips
@matthewp
Mar 10 2015 18:01
alpha.10 used "canjs" i believe
alpha.10 is can
oh sorry, alpha.9 was canjs
Curtis Cummings
@ccummings
Mar 10 2015 18:17
the current package gives me the entire contents of the repo. is that what we will publish to npm? I thought just the dist would be published
Curtis Cummings
@ccummings
Mar 10 2015 18:28
also main is ./can so this won't work with Browserify without copying the browser config from the package,json into my own
Justin Meyer
@justinbmeyer
Mar 10 2015 18:31
@ccummings the entire contents
so they can be used by stea
l
@ccummings it should work
Curtis Cummings
@ccummings
Mar 10 2015 18:32
There is a steal folder inside dist..
Justin Meyer
@justinbmeyer
Mar 10 2015 18:32
that's "steal" format
(which happens to be the format the main stuff is written in)
(but might not be in the future)
@ccummings to be clear, you shouldn't have to copy browser config
unless CanJS's is missing a mapping for "./can": "./dist/can/can"
it has it
are you using the latest browserify?
Justin Meyer
@justinbmeyer
Mar 10 2015 18:37
@matthewp looks like that needs to be pointing at "can"
Matthew Phillips
@matthewp
Mar 10 2015 18:38
i'm looking into that
I'm not seeing a dist folder in 2.2.0-alpha.10
Curtis Cummings
@ccummings
Mar 10 2015 18:49
@justinbmeyer Using latest browserify and require('can') works, but requiring anything else does not. Example: require('can/view/stache/stache')
It loads the steal version of stache which errors
Matthew Phillips
@matthewp
Mar 10 2015 18:54
@ccummings you're testing this on 2.2.0-alpha.10?
do you have any idea why, missing mapping for stache maybe?
Curtis Cummings
@ccummings
Mar 10 2015 19:04
The mapping for stache is "./view/stache/stache": "./dist/cjs/view/stache/stache"
require('can/view/stache/stache'); just loads node_modules/can/view/stache.stache.js
Matthew Phillips
@matthewp
Mar 10 2015 19:06
hat's weird, when i npm install 2.2.0-alpha.10 it doesn't contain a dist directory
Curtis Cummings
@ccummings
Mar 10 2015 19:07
I've downloaded with package.json and just npm install can and both had a dist
Alexis Abril
@alexisabril
Mar 10 2015 19:19
just to clarify, here's what I'm seeing: http://screencast.com/t/5sHUBLZpCA
Matthew Phillips
@matthewp
Mar 10 2015 19:24
crazy weird
yeah, i downloaded the tarball, it's in there
probably npm cache issue
Curtis Cummings
@ccummings
Mar 10 2015 19:32
@alexisabril have you tried can with browserify?
Matthew Phillips
@matthewp
Mar 10 2015 19:33
i'm seeing the same issue with stache
Alexis Abril
@alexisabril
Mar 10 2015 19:34
@ccummings I have not tried with browserify as of yet
Justin Meyer
@justinbmeyer
Mar 10 2015 19:36
@ccummings did you write that right?
require('can/view/stache/stache'); just loads node_modules/can/view/stache.stache.js
Curtis Cummings
@ccummings
Mar 10 2015 19:37
What should it be?
Justin Meyer
@justinbmeyer
Mar 10 2015 19:40
node_modules/can/view/stache/stache.js
@ccummings
a slash (/) not a dot (.)
Matthew Phillips
@matthewp
Mar 10 2015 19:40
yes, that's what i'm getting
Justin Meyer
@justinbmeyer
Mar 10 2015 19:41
which one?
Matthew Phillips
@matthewp
Mar 10 2015 19:41
slash
Curtis Cummings
@ccummings
Mar 10 2015 19:41
oh sorry, yes that was a slight typo
Matthew Phillips
@matthewp
Mar 10 2015 19:41
it browserifies without error
Justin Meyer
@justinbmeyer
Mar 10 2015 19:41
ok, so the mapping isn't happening
Matthew Phillips
@matthewp
Mar 10 2015 19:41
but it picks up the wrong file in this case
Justin Meyer
@justinbmeyer
Mar 10 2015 19:41
did browserify undo my changes?
Matthew Phillips
@matthewp
Mar 10 2015 19:42
i can't find the related issue
Justin Meyer
@justinbmeyer
Mar 10 2015 19:42
substack/node-resolve#63
seems like he redid it: substack/node-resolve@60ff554
Matthew Phillips
@matthewp
Mar 10 2015 19:45
possibly this
defunctzombie/node-browser-resolve#56
Justin Meyer
@justinbmeyer
Mar 10 2015 19:46
so maybe "./can": "./dist/cjs/can"
needs to look like
"./can": "dist/cjs/can.js"
Matthew Phillips
@matthewp
Mar 10 2015 19:47
all of them or just can?
Justin Meyer
@justinbmeyer
Mar 10 2015 19:47
all of them
Matthew Phillips
@matthewp
Mar 10 2015 19:47
i can try this locally
Justin Meyer
@justinbmeyer
Mar 10 2015 19:47
there's a grunt task
Matthew Phillips
@matthewp
Mar 10 2015 19:47
ok
Justin Meyer
@justinbmeyer
Mar 10 2015 19:47
that writes this out
Matthew Phillips
@matthewp
Mar 10 2015 19:47
yeah i know, but i can test this quickly
Justin Love
@JustinLove
Mar 10 2015 19:49
@justinbmeyer tabbed sections, where each section can have item ids and possibly custom routes below that. I tried making a jsbin, but it didn't have the issue - click on twos, twos/1, twos-back, and the full app with components is resetting 'section' to the default value.
Justin Meyer
@justinbmeyer
Mar 10 2015 19:51
?
not sure what "twos" is
oh
its in your jsbin
oh so in your app, section is not "twos" after you click twos-back
oh
can.route(':section')
can.route(':section/:one_id')
can.route(':section/:one_id/:one_section')
can.route(':section/:two_id')
are not valid routes
b/c a route like
foo/bar
will always match :section/:one_id
never :section/two_id
arg
@JustinLove
so, do you have a finite number of :section values?
Justin Meyer
@justinbmeyer
Mar 10 2015 19:56
arg
\:section values
not sure how to prevent :s from showing up
you probably want only one route like can.route(':section/:id')
and listen to when "id" changes, but make sure section is "twos"
or "ones"
the "delegate" plugin used to make this easier
but computes can make this easier too
var twosId = can.compute(function(){  
  if(can.route.attr("section") === "twos") return can.route.attr("id")
})
or this can be done with a define.get
but twosIds would be undefined or a value
Justin Love
@JustinLove
Mar 10 2015 20:22
I was experimenting with an extra path component to disambiguate routes, did not help. Is the number of variables the issue? Sections are finite; two bindings used to sync it to foundation tabs.
Justin Meyer
@justinbmeyer
Mar 10 2015 21:18
what are foundation tabs?
Justin Meyer
@justinbmeyer
Mar 10 2015 21:25
@Aldredcz Just asked what will be in 2.2
David Luecke
@daffl
Mar 10 2015 21:26
Justin Meyer
@justinbmeyer
Mar 10 2015 21:26
@Aldredcz 2.2 won't have many of the features on http://canjs.com/blog/2014/09/2.2-features.html unfortunately
however, they are still on our target for 2.3
instead, we wanted to get out a release of CanJS that worked with CJS / Browserify / SystemJS / StealJS
It will have an improved Guide, improved docs
can-animate is a plugin
Oh, and we are trying to have a release this week
oh, and somewhat ironically
some of the on-deck features are done
in-page templates
(somewhat)
Vojtech Prikryl
@Aldredcz
Mar 10 2015 21:29
i've seen the tabs demo, with autorender option, so that means I can directly render starting stache template and let's say fire off app by some wrapper component, right
Justin Meyer
@justinbmeyer
Mar 10 2015 21:29
and can-event arguments
yes
Vojtech Prikryl
@Aldredcz
Mar 10 2015 21:30
will come handy :)
btw. one thing I was missing, but didn't actually open Issue - specifying can-value event-type on input/textarea (update on blur/keyup/change/...), isn't it there by any chance?
Justin Meyer
@justinbmeyer
Mar 10 2015 21:52
@Aldredcz nope, but now that we have all this infrastructure
Justin Love
@JustinLove
Mar 10 2015 21:52
The real issue was that I had a bunch of href="#" leftover from some sample code, which wasn't an issue until hashchange routing got turned on. Sorry for the trouble.
Justin Meyer
@justinbmeyer
Mar 10 2015 21:52
it should be easy to get out releases more often
ah
btw, it's best to create those links with can.route.link
(or have a helper that calls can.route.link)
(we are planning an can-href helper for 2.3)
that way, users can right-click the link
and open in a new page