How to make holder.js work together with Sinatra - sinatra

Holder.js needs a calling syntax of "/holder.js/200x300" which includes a slash. The slash before the size is not recognised by Sinatra routing and can only result in "Sinatra doesn’t know this ditty." page.
How to make holder.js and Sinatra work together?

Use data-src attribute to avoid 404 errors:
<img data-src="holder.js/200x300" src="">

If you use the standard public folder i think you need to add a slash like this
"/holder.js/200x300"
Example Code: https://bitbucket.org/l33tname/holder.js-sinatra-example/src

Related

TYPO3 extension - f:uri.resource returns wrong path

I'm writing a backend module for my own TYPO3 extension, where I'm wrapping the content into a be.container including a CSS and a JS file:
<f:be.container
includeCssFiles="{0: '{f:uri.resource(path:\'CSS/backend.css\')}'}"
includeJsFiles="{0: '{f:uri.resource(path:\'JS/backend.js\')}'}"
>
<!-- module content -->
</f:be.container>
None of those resources gets included though. When I'm rendering f:uri.resource directly into the HTML, it - no matter which path - resolves to
/typo3/
which makes no sense to me. In my project, /typo3/ is the path where the TYPO3 core is symlinked to, relative to my web path.
I've assured that my resource files are placed in EXT:my_extension/Resources/Public/CSS/backend.css and EXT:my_extension/Resources/Public/JS/backend.js respectively. I had a similiar issue including resources in the frontend, where it would resolve to just a / - in the end I decided to go with inclusion via Typoscript instead. I'm not sure if I'll be able to do this for the backend module as well. Any idea how to solve this? Maybe I missed something in the configuration which messes up path resolution for f:uri.resource. Any help would be appreciated.
For a minimal test case, try putting the plain output into your fluid template:
{f:uri.resource(path:'CSS/backend.css')}
If that yields the same result, it seems like the ViewHelper is not aware of the current extension. You can pass it the extension key as argument, see https://docs.typo3.org/other/typo3/view-helper-reference/9.5/en-us/typo3/fluid/latest/Uri/Resource.html.

CodeIgniter send()) fail

I am learning how to use code igniter and following tutorials. As this is my first time to use MVC, I'm having some trouble implementing the send function. I am doing a tutorial on how send a newsletter sign up form.
For some reason when I hit submit with or without the info, its giving me a 404 page not found with the /send extension. Is there something I'm missing in my config file?
Here is the code
Thanks in advance.
Is not send that is failing but you missed something in your config.
http://codeigniter.com/user_guide/general/urls.html
You should set up your .htaccess according to the guide above.
Did you setup the CodeIgniter rewrite rules in your .htaccess?
Apart from the htaccess possible problem, there are a couple of things wrong in the file you posted:
1) the html <title>HEY<title> before the php class, but I hope that's a typo, right? you don't have html in your controller file, right?
2) You're getting the POST variable wrong; or better, you're confusing and mixing things.
Instead of
$this->input->$_POST('name'); //which is also sintactically wrong
should be:
$this->input->post('name').
The input class already does the retrieving of this superglobal. And unsets them in favour of its own.
3) To use an attachment, you need to call
$this->email->attach($filename);
You just declared a variable and nothing else.
4) What is $this->email->set_newline("\r\n"); ?
I don't see this function in the email class...You need to use a config file for this, or pass the value on library's inizialization:
$config['newline'] = "\r\n";
$this->email->initialize($config);

zend headScript()->appendFile in IE (internet explorer)

Two lines of script
$this->headScript()->appendFile('/js/global.js', 'text/javascript');
$this->headScript()->appendFile('http://zendbase/js/global.js', 'text/javascript');
Firefox runs script by both ways(absolute, root relative)
Internet Explorer only run the Second method of append(absolute), which is with http. which is not a good way.
when I view source in browser I can see following line is added
<script type="text/javascript" src="/js/global.js"></script>
But browser is not reading. it is really beyond my understanding. It is strange. How can I make first line to work with document root path on all browsers including IE.
Is there any settings in view helper? or something else?
I can use $_Server variables to make it absolute dynamically but i don't want to use absolute path.
Any Idea. Thanks in advance :)
Relative paths for scripts will definitely work with IE - I have used it numerous times... What is the hostname you are using (e.g. www.example.com)? Your second line of code should not work, because you don't have a valid hostname - http://zendbase won't resolve to anything. Is zendbase a variable?
For relative static assets (images, JS, CSS, SWF, etc), you should always use the baseUrl helper, eg
$this->headScript()
->appendFile($this->baseUrl('/js/global.js'));
If you can see the correct <script> tag in source, then the problem is either the path is incorrect (see baseUrl helper above) or your JavaScript contains errors.
Finally I fixed the problem
I removed the baseUrl(); ?>" /> from layout.phtml
and added following line in application.ini
resources.frontController.baseUrl = ""

zend framework under document root in subdir

I developed a application with Zend Framework and now I want to be able to place the app in an subdirectory of a Documentroot.
e.g. http://www.example.com/myapp/
I read quite a lot of Docu how this could work, but all in all these solutions don´t fit my needs. Is there a trivial way to do the subdir thing, without adding the concrete path to any file which generates the pages.
There are some examples in the net, where a basePath is set in the application enviroment and so there is a method call bevor each "form" creation which prepends the path before the link.
$form->setAction($this->_request->getBaseUrl() . $this->_helper->url('sign'));
This was from: http://johnmee.com/2008/11/zend-framework-quickstart-tutorial-deploy-to-a-subdirectory-instead-of-web-root/
But this is only works for small examples, I have tons of forms, tons of views and tons of scripts. I can´t belive this (lets call it hack :) ) is the only solution to do this.
Any ideas?
You don't have to do anything special. See my tutorial at http://akrabat.com/Zend-framework-tutorial which is developed entirely within a sub-directory.
As they say on the web page:
I’m told this last issue has been
lodged has a defect and not necessary
from releases “1.7″ and beyond. The
helper->url will henceforth prepend
the baseUrl to its result.
So you should be fine. Do you actually use the $form->setAction() method on every form already? Because if you use it in combination with the url helper, the baseUrl will already be included.

Making GWT application crawlable by a search engine

I want to use the #! token to make my GWT application crawlable, as described here:
http://code.google.com/web/ajaxcrawling/
There is a GWT sample app available online that uses this, for example:
http://gwt.google.com/samples/Showcase/Showcase.html#!CwRadioButton
Will serve the following static webpage to the googlebot:
http://gwt.google.com/samples/Showcase/Showcase.html?_escaped_fragment_=CwRadioButton
I want my GWT app to do something similar. In short, I'd like to serve a different flavor of the page whenever the _escaped_fragment_ parameter is found in the URL.
What should I modify in order for the server to serve something else (a static page, or a page dynamically generated through a headless browser like HTML Unit)? I'm guessing it could be the web.xml file, but I'm not sure.
(Note: I thought of checking the Showcase app provided with the GWT SDK, but unfortunately it doesn't seem to support serving static files on _escaped_fragment_ and it doesn't use the #! token..)
If you want to use web.xml, then I think it won't work with a servlet-mapping, because the url-patterns ignore the get parameters. (Not 100% sure, if there is another way to make this possible.)
You could of course map Showcase.html to a servlet, and in that servlet decide what to do, based on the get parameter "_escaped_fragment_". But it's a little bit expensive to call a Servlet just to serve a static page for the majority of the requests (not too bad, but still. You could set cache headers, if you're sure that it doesn't change).
Or you could have an Apache or something in front of your server - but I understand, I wouldn't like to have to do that either. Maybe your JavaEE server (which one are you using BTW?) provides some mechanism for URL filtering before the request gets passed on to the web container - I'd like to know that, too!
Found my answer! The Showcase sample supporting crawlable hyperlinks is in the following branch:
http://code.google.com/p/google-web-toolkit/source/browse/branches/crawlability/samples/showcase/?r=7726
It defines a filter in the web.xml to redirect URLs with the _escaped_fragment_ token to the output of HTML Unit.