Equivalent for Dancer of Mojolicious Mojolicious::Plugin::PODRenderer? - perl

I would like to generate documentation in a Dancer application in the same way that Mojolicious does with Mojolicious::Plugin::PODRenderer, I mean in the browser, under the /perldoc path.
Does somebody knows a module that can help? I found no ready-made plugin for Dancer. If it don't exist, any recommandation is welcome.

Porting Mojolicious' PODRenderer to Dancer should be fairly simple - it's an example plugin and the code is fairly short. I've done this for my own use in my CGI framework at work.
https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Plugin/PODRenderer.pm#L34
Essentially what the plugin does is define the route /perldoc/:module to call the _perldoc method; the _perldoc method uses Pod::Simple::Search to find a documentation file matching the module param in the #INC directories; If it doesn't, it redirects the search to MetaCPAN. If it does, it uses Pod::Simple::HTML to convert the documentation to HTML, which is then tidied up with Mojo::DOM and wrapped in a lovely template.
Finding the location of that template is left as an exercise for... oh, nevermind, here it is: https://github.com/kraih/mojo/blob/master/lib/Mojolicious/templates/perldoc.html.ep

Related

Modern core method of uploading file in Perl

I'm looking to write a script that lets a user upload an image from a webpage, for later use on that website. As per usual, all I can find is examples involving CGI.pm. Are there any core modules that I can use as a replacement?
The Perl core distribution contains no modules for writing web applications. I think you probably want something based on Plack::Request and Plack::Request::Upload (for example Dancer2::Core::Request::Upload).
The solution I ended up going with may not be the best, but it's functioning, and simple.
Using cgi-lib.pl I can simply use
open(VAR, ">output/file.png");
binmode VAR;
print VAR $in{input};
close(VAR);
and it gets the job done.
If there are any notable problems with this, please let me know.

Include CoffeeScript into another one

It is a noob question, but I am looking for a solution, to include one coffeescript into another one, like in SASS or Pug(former Jade).
Like in sass:
#import ../sass/vars.sass
or in jade
include ../jade/footer.jade
I cannot find something like this in CoffeeScript. Is there any way?
Coffeescript is just a semi-language that is being translated into JS later on anyways, it does not allow modularization by itself. To build your app module-way, i prefer to use RequireJS, it works fine with CS.
http://requirejs.org/

Perl library for simple torrent downloading?

I am in need of a library for perl that will let me download files from torrents and magnet links in a simple way. Does anyone have any suggestions? Thanks!
Several such libraries include:
Net::BitTorrent or here , with documentation here
Protocol::BitTorrent
Several existing Perl BitTorent clients include:
Bitflu
AnyEvent::BitTorrent
Basic Net::BitTorrent Client
Also see this related question.

How does filepicker work in XUL::Gui?

I'm starting to have a love/hate relationship with XUL::Gui. I love it because the simple pieces are easy to use, but I hate it because its documentation is horrible.
In particular, I'm trying to use the filepicker function (listed under gui functions in the main doc), but whenever I try to use it--even by copying and pasting the code example in the documentation--the filepicker command seems to go unrecognized ("Bareword 'filepicker' not allowed while 'strict subs' in use").
My apologies if I'm missing anything obvious, but how is this function used in XUL::Gui?
The filepicker is not exported by default, it is part of the :widgets export tag.
You can either use use XUL::Gui ':all'; to get everything, or use use XUL::Gui qw(:default filepicker); to get the default set of imports and the filepicker.
Take a look at the EXPORT heading for more details.
Sorry the documentation is horrible, its a work in progress :)

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.