Building a blog engine using Perl Dancer

Building a blog engine using Perl Dancer

Hey. I’m going to show you how the menu items of Padre work one by one. This time I’m showing the file menu, actually, the more important parts of the file menu. So when you open Padre you get this unsaved file here, and you can start typing in. For example I’ll just type in 0.84, to remind you that this is now showing Padre version 0.84, running on Windows. The same would happen, the same would work on Linux, it’s the same version of Padre, but you might have a different version, so there menu items might be slightly different, or behave slightly different. I will post newer versions of the screencast later on. So if you go to the File menu, the first item is New, which is just the standard New menu item, it creates you a new empty buffer where you can type in code. Then there’s another menu item called New, with some submenus. If you click on the first one, Perl 5 Script, which creates you a new editor with some skeleton content in it, there are the use statements, the skeleton statements which you probably want to use for your Perl code – except that this line requires Perl 5.6, and you could probably want to have higher version number, so you would probably require 5.10, or even newer version of Perl. New menu items also has the Perl 5 Module, in this case it provides you with a pop-up window, that remembers the last one you typed in. Here you type in the name of the module, for example Module::Name, and clicking OK will create an editor window, with skeleton module in there – package, the module name, then the use statements, some documentation, and even a constructor and a simple method in it. Now it would be probably nice if these skeleton files could be configured by the user, unfortunately as far as I know currently these are hard-coded in Padre, so unless you actually change the files that are supplied by the installation of Padre… now, currently it’s hard-coded. You can also create a test file the same way, and a Perl 6 script, which is, because Padre currently in this version doesn’t have Perl 6 support, you don’t see syntax highlighting there. The last item I’ll skip over right now, because in this version of Padre it doesn’t work correctly. Open – will open you a standard file browser, where you can pick one file, then open it and it’ll open the file and it lets you edit. The other Open menu has several submenus, so, Open URL would allow you to type in some kind of a URL, let’s say what you can see here, it’ll fetch the file and open the file in this editor. It’ll open it in read-only mode, so if you want to actually save the file, then you will have to do it with Save As. Open Selection – so let’s go back here, and for example in this module I have a use statement, or just some kind of a name of a module, I can highlight the name of the module, then go to the Open, Selection – or Ctrl-Shift-O, and it’ll look for that module in your file system, within your @INC, and find the file that implements that module, and open it for you for editing. In case you have several copies of this, then you’ll get a menu where you can pick which one you would like to open. Open file in browser – will open just a standard file browser of your operating system, so in this case it’s Windows, in Linux it’s probably Nautilus or some other kind of file browser. It’ll open in the directory where the current file is saved. Open with default system editor is currently not working, at least not on my system, Open in command line will open a command window – the cmd window on Windows, in the place where the current file is, so you can type in “dir” and you can see the files. The same works on Linux, opening a shell terminal window. Open example, here – the last one – is again just a standard file opening dialogue, but in a directory that was supplied by Padre, where you can see a couple of example scripts. So here are some examples for beginners, and here are a couple of examples that are using wxWidgets to create various windows. Close would just close this file, if the file was changed it’d ask first whether you want to save it. Then there’s this other Close menu which has several entries, so you have Close this project, or Close other projects – that’s for projects, I won’t deal with that now – Close all files, that would close all the files currently open, or Close all other files, that would close all the files except the one that I’m currently editing. And Close files will allow you to pick which ones you would like to close. Now in our case, because that file was already changed, and just telling if you want to save it, no I don’t want to save it, so it will close that file now. That’s what it does. Reload – when you’re editing a file, and then outside of Padre you could, let’s say, svn update, or for git you fetch new version of files, so the files get out of sync, there’s a newer version of file on the file system. Padre will automatically recognize this, but you might cancel that operation, due to whatever reason, so with this you can tell Padre to reload the file, getting rid of the current version that you have in the editor. You can tell it whether to reload a single file, all of the files or just some of them. Some of them you will pick here, which ones you’d like to reload, now in this case we have three editor windows open that are not related to files yet. Save – that’s just normally saving the file, Save As would allow you to pick a different name for the file and save it that way. Save Intuition – that’s what I’m going to take a look at later on, when I’m talking about projects. Save all the files. Now sessions – Open Session and Save Session. Basically a session is just a set of files in Padre. So you would edit three of four files for one project probably, then another three of four files for another project – and we call these sessions, because those files don’t necessarily belong to one single project entity, in the sense of a Perl project. So, for example, let’s close all these, all the other files, let’s say, so if I come here, and I say close all other files, and it will ask me for each one of them whether I want to save it, but I don’t want to save them. So here is one file. And I would like to save this session, currently which has only one file in it. So I save the session, like this, I call it “example”. I could type in some description here but that’s not that important, and I save that session. I close the file and then I go to the File menu and click on Open session. It’ll list all of my sessions. So currently I have two sessions in this editor, and I pick the “example” session, and I click on Open. Now, here, there is a checkbox, probably you want to check that checkbox. What is does is, when you are opening more files in you current session, it automatically remembers those files, so next time when you open the session, those files will be opened as well. So I open this “example” session, and I got that specific file. If I open another file, let’s say this file, I open, and I close them, I close all the files now, or instead of that I open a session, a different session. Let’s say, I open the dwimmer session. Then this will close all the other files – all the files that didn’t belong to that session, and open the files that were in the dwimmer session. And I can open a session again, and go to the “example”, and it remembers both of the files in that session. Print – I’m not sure if it works or not, but I don’t think that’s currently that important. Recent files, it just lists you the files that you have opened recently. And this will just remove all the entries from the list, or open all of them. Finally, Document Statistics will provide you with some information about your current document. So that’s it about the File menu, and the next time I’ll show about the Edit menu. Thank you for listening.

Author: Kevin Mason

16 thoughts on “Building a blog engine using Perl Dancer

  1. thank you gabor, this tutorial did more for me than all the written tutorials out there on dancer. makes so much more sense when you explain not just how but why you do the coding you do. detailing the entire workflow really helps. one more thing for yaml newbies like me… DONT USE TABS

  2. Thanks, that is enough of a kick start to get me writing a dancer app. I like your videos, they are always to the point and informative.

  3. Hi Gabor, thank you for the great example/demonstration on Dancer. I'm quite new to web application development, but I do have perl experience. This video shows how fun web devel. can be!

  4. Very good work! I have PERL scripting experience but never done web development.
    This video is better than all the documentation I have found


  5. Thanks Gabor Szabo for this wonderful post. Can you share a video for hosting Perl Dancer App on Cpanel. Also, can you post the same for Mozolicious on Cpanel.

Leave a Reply

Your email address will not be published. Required fields are marked *