Default layout for ember-cli, instead of "UnrecognizedURLError - ember-cli

I have something like this:
{{topbar-nav}}
{{outlet}}
I have a lot of pages, where I want to render just the top-bar, and nothing else. Normally, I have to create a lot of routes, that would basically do nothing (rendering emptiness), and I don't want to pollute router like this. Is it possible to somehow handle this situation? For example a default route like:
this.default_route("default");

Well, I found it myself.
this.route('default_page', { path: '/*wildcard' });
Important part is
{ path: '/*wildcard' }

Related

Frontend headless browser testing using CasperJS and configuration-files?

I tried to use CasperJS for headless browser testing using PhantomJS and wanted to have a config file or something to change Website URL, Username passwords etc. So finally I found NuclearJS. Do you guys know any other perfect way to do this? If I wanted to write a one from the scratch would like to know about as well.
I got a solution (not perfect ;) ) that is using multiple configfiles (for selector, execution, desktop, mobile, etc).
I include a in the execution of my casperjs tests a file that offers me all configs i need (i include also global functions there).
Lets guess the test execution looks like that:
casperjs test --includes=loadGlobals.js test_1.js
In the that example loadGlobals.js contains functions like that:
var fs = require('fs');
var config = {},
configFile = fs.read('config.json');
config = JSON.parse(configFile);
Probalby the config.json is looking like that:
{
"url": "http://www.yourTestUrl.com",
"variable_1": "bla",
"variable_2": "blub",
"nextTier": {
"variable_1": "blablub"
}
}
Now you can call in the test_1.js the variables of the config.json:
casper.start(config.url, function() {
casper.then(function() {
casper.echo(config.variable_1);
casper.echo(config.variable_2);
casper.echo(config.nextTier.variable_1);
});
})
casper.run();
You can use like that different configurationfiles, even to override it during tests if nessacary.
The tests should be written in the page object pattern style so they are highly maintable, espacially with a outsourced configuration.
NuclearJS i didn't know, but i will take a look into it, too.

Dynamic assets prefix in Ember-CLI build-generated index.html

I asked this question earlier today, and then deleted it, cause I thought I found an answer that was too obvious to post on here. Basically, how do you change something like this in dist/index.html:
<script src="assets/my.js"></script>
to something like this:
<script src="http://my.assets.com/assets/my.js"></script>
I instantly realized that I can just set the src in app/index.html and it will appear in dist/index.html.
But now I'm realizing that there's a better, if slightly more complex, solution - one that allows different settings in different environments. So I am re-adding the question and posting the answer below.
The solution requires ember-cli-inline-content
Brocfile.js:
global require, module, process;
...
if (process.env.EMBER_ENV === 'development') {
app.options.inlineContent = {
assetPrefix: {
content: 'http://my.assets.com/'
}
};
}
index.html:
<script src="{{content-for 'assetPrefix'}}assets/my.js"></script>

Autoscale text input with JEditable.js?

I've been looking for a script that combines the autoGrowInput with the JEditable but found none.
Use https://github.com/MartinF/jQuery.Autosize.Input initialized automatically via jEditable's event data:
jQuery(element).editable(save_fn, {
data: function(value,settings} {
var target = event.target;
window.setTimeout(function(){
jQuery(target).find('input').autosizeInput();
});
return value;
}
});
It's worth noting that this event (data) fires before the input element is actually created, hence the use of the timeout. There doesn't seem to be an event available at the present time for after the input has been created.
Actually I have created a plugin that does exactly that. You can check the demo and the documentation. I tried to make it very intuitive. It has ajax capabilities, using the RESTful philosophy. If you liked the animation effect on the autoGrowInput, it will be really easy to add it to the plugin just by changing the css file, using the transition property.
If I get people to like it, I may be able to improve and add more features to it. Hope it helps.

Zend Router Question

I use modules layout to structure my controllers:
:module/:controller/:action
I would like to add a new custom route so that the following url will work.
domain.com/username
where username is a username of any registered user on the website.
Can anyone point me in the right direction?
Thank you
See this blog post for a detailed explanation of how to do this in ZF:
http://tfountain.co.uk/blog/2010/9/9/vanity-urls-zend-framework
Not sure if you can make something like domain.com/username. Instead you could do domain.com/u/username or domain.com/user/username. For example, to make the second route in you application.ini you could put something similar to the following:
resources.router.routes.user.route = "/user/:user"
resources.router.routes.user.type = "Zend_Controller_Router_Route"
resources.router.routes.user.defaults.module = default
resources.router.routes.user.defaults.controller = user
resources.router.routes.user.defaults.action = user
resources.router.routes.user.defaults.user =
resources.router.routes.user.reqs.user = "\s+"
http://framework.zend.com/manual/en/zend.controller.router.html covers quite well all the different ways you can add routes. Keep in mind, once you add custom routes, the default one will not work anymore unless you explicitly define it (as well as in url view helpers etc.).

Mediawiki process tag after templates tranclusion

Is there any way to do something like that.
I have next wiki text:
{{template_open_tag}}
{{template_some_data}}
{{template_close_tag}}
And there are templates:
{{template_open_tag}}
<my-tag>
{{template_some_data}}
bla-bla-bla...
{{template_close_tag}}
</my-tag>
But tag '<bold>' processed already when first template transluded and wiki render this page like:
bla-bla-bla...
</my-tag>
But I want to see:
**bla-bla-bla...**
In my extension:
$wgHooks['ParserFirstCallInit'][] = 'myTagInit';
function myTagInit( &$parser ) {
$parser->setHook( 'my-tag', 'myTagRender' );
}
function myTagRender( $input, $args, $parser, $frame) {
return "**".$input."**";
}
Thank you.
P.S.
And don't ask me why I need this strange markup and don't want to use something like this:
{{template_tag|{{template_some_data}}}}
And {{template_open_tag}} like:
<my-tag>{{{1}}}</my-tag>
To warn you -- this sort of structure will likely be phased out entirely in future versions of MediaWiki, due to its inconsistent behavior and the difficulties it causes with structures like tags and sections.
The correct and future-proof way to do it is indeed to contain both your start and end in one template and pass the middle in as a parameter, eg {{template_tag|{{template_some_data}}}}
Set $wgUseTidy to true to make MediaWiki remove unclosed tags only after all the templates have been evaluated. Alternatively, you can use wikimarkup - as Adrian said - which does not suffer from this limitation.
Update: AFAIK XML-style extension tags are evaluated before way template including happens, so piecing them together from multiple templates is not possible. (Event <ext>{{{1}}}</ext> does not work pre-1.16, though you can make it work in 1.16 with recursiveTagParse.)
instead of using <bold> use ''' in both your {{template_open_tag}} and {{template_close_tag}} and it should render as bla-bla-bla...
Also, you can't do:
{{template_open_tag}}
{{template_some_data}}
{{template_close_tag}}
You have to do
{{template_open_tag}}{{template_some_data}}{{template_close_tag}}