Welcome, Guest :: Blog Home | Login | Register

Articles
Domain Lister v1.0 - Catalyst MVC Application
2008-04-21 23:14:48 Permalink

Tags: catalyst perl mvc mysql


I am currently hard at work developing a new domain name auction, well an offer/counter-offer, application for MySQLSoftware.net. This system, powered by the Catalyst MVC Web Framework, will replace my existing domain name auction software. I'll be updating the MySQLSoftware.net website soon with more detailed information regarding the release.

All previous software versions will not be considered deprecated, as I will no longer provide support for them. The new application will require a good bit of maintenance/support to new clients, so there will be a maintenance plan implemented once the new version is ready for deployment.

Stay tuned for further details, including a demo version via FastCGI implementation. Mainly administration features are needing finishing touches, including the ability to generate additional administrator accounts.

Screen Shot:


Regards,
Stephen

[ Comments (0) ]


Template::Plugin::HighlightPerl
2008-04-16 21:09:57 Permalink

Tags: perl template toolkit cpan


CPAN Link:

http://search.cpan.org/perldoc?Template::Plugin::HighlightPerl

I just uploaded my new module to CPAN. The module is a TT2 (Template Toolkit) filter which can be used for blog posts where Perl code is to be shown. It is a sort of wrapper for the Syntax::Highlight::Perl module and is used within the template file (.tt2) as a filter. I say "sort of" because it is really much more than that. It will "dynamically" highlight all perl code based on syntax and includes a css div classes for custom formatting. It also can be used to format non-perl code by using a different set of tags.

Here's a sample of the dynamically generated syntax highlighting.

Perl Code:
package Template::Plugin::HighlightPerl;

use Syntax::Highlight::Perl;
use Template::Plugin::Filter;
use base qw( Template::Plugin::Filter );
use strict;

our $VERSION = '0.01';

sub init {
    my $self = shift;
    my $name = $self->{ _CONFIG }->{ name } || 'highlight_perl';
    $self->install_filter($name);
    return $self;
}


[ Comments (0) ]


Fedora 8 Linode Server SVN and Trac
2008-04-14 19:28:28 Permalink

Tags: fedora svn trac linode


I created this document as a record of how to setup subversion with trac integration on a Linode VPS server running
Fedora 8 OS. I am posting the doc here for others who may need help getting there development environment setup. Hope you find it useful. If you have an questions, feel free to give me a shout.

Note: Steps 1-19 are commands run on remote server.

1) Install SVN and Trac.

Code:
yum install trac svn mod_dav_svn


2) Let's make our directory structure including any parent directories all in one go with the -p option, one for svn
repo and one for trac.

Code:
mkdir -p /var/svn/svn.mydomain.com/repo
mkdir -p /var/trac/trac.mydomain.com/repo


3) With svn installed we use the following command to create our repo.

Code:
svnadmin create --fs-type fsfs /var/svn/svn.mydomain.com/repo


4) Let's make our first import/revision by using svn to create our revision structure.

Code:
svn mkdir file:///var/svn/svn.mydomain.com/repo/branches file:///var/svn/svn.mydomain.com/repo/tags file:///var/svn/svn.mydomain.com/repo/trunk -m "Initial Structure"


5) Now we create our trac files.

Code:
trac-admin /var/trac/trac.mydomain.com/repo initenv

- Enter name of project.
- Just press enter to use SQLite
- Just press enter to use svn integration.
- Templates directory defaults to /usr/share/trac/templates
- Path to repo: /var/svn/svn.mydomain.com/repo


6) Now we setup proper permissions on our directory structure.

Code:
chown -R apache.apache /var/svn/svn.mydomain.com/repo
chown -R apache.apache /var/trac/trac.mydomain.com/repo


7) Modify subversion config.

Code:
vim /etc/httpd/conf.d/subversion.conf


8) Add the following.

Code:
<Location /var/svn/svn.mydomain.com/repo>
        DAV svn
        SVNPath /var/svn/svn.mydomain.com/repo>
        AuthType Basic
        AuthName "Repo Repository"
        AuthzSVNAccessFile /var/svn/svn.mydomain.com/svn-acl-conf
        AuthUserFile /var/svn/svn.mydomain.com/repo.htpasswd
        Require valid-user
</Location>


9) Create empty .htpasswd file for svn authentication.

Code:
touch /var/svn/svn.mydomain.com/repo.htpasswd


10) Add user to .htpasswd auth file, you'll be prompted for password.

Code:
htpasswd -m /var/svn/svn.mydomain.com/repo.htpasswd username


11) Now we create our ACL authentication.

Code:
vim /var/svn/svn.mydomain.com/svn-acl-conf


12) Add our user to svn-acl-conf.

Code:
[repo:/]
username =  rw


13) Modify trac config.

Code:
vim /etc/httpd/conf.d/trac.conf


14) Add the following pre to trac.conf.

Code:
<Location /trac/repo>
	SetHandler mod_python
	PythonHandler trac.web.modpython_frontend
	PythonOption TracEnv /var/trac/trac.mydomain.com/repo
	PythonOption TracUriRoot /trac/repo
</Location>
<Location "/trac/repo/login">
	AuthType Basic
	AuthName "trac"
	AuthUserFile /var/trac/trac.mydomain.com/repo.htpasswd
	Require valid-user
</Location>


15) Create the .htpasswd file for trac authentication.

Code:
touch /var/trac/trac.mydomain.com/repo.htpasswd


16) Give our user trac-admin permission.

Code:
trac-admin /var/trac/trac.mydomain.com/repo permission add username TRAC_ADMIN


17) Setup apache.

Code:
vim /etc/httpd/conf/httpd.conf


18) Add virtual host config.

Code:
# Trac Configuration
<VirtualHost *:80>
  ServerName trac.mydomain.com
  Alias /trac/ /usr/share/trac/htdocs
  <Directory "/usr/share/trac/htdocs/">

      Options Indexes MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all
  </Directory>
  <Location />
      SetHandler mod_python
      PythonHandler trac.web.modpython_frontend
      PythonInterpreter main_interpreter
      PythonOption TracEnv /var/trac/trac.mydomain.com/repo/
      PythonOption TracUriRoot /
        AuthType Basic
        AuthName "trac"
        AuthUserFile /var/trac/trac.mydomain.com/repo.htpasswd
        Require valid-user
  &glt;/Location>
</VirtualHost>


19) Restart Apache.

Code:
service httpd restart


20) Import our project files from local box.

Code:
svn import -m "Initial Import" --username=username /srv/www/repo http://svn.mydomain.com/trunk


21) Change into server.

Code:
cd /var/www/mydomain.com


22) Checkout to live site.

Code:
svn co --username=stephen http://svn.mydomain.com/trunk .


23) Use the copy command to version the live site.

Code:
svn copy --username=stephen http://svn.mydomain.com/trunk http://svn.mydomain.com/tags/deploy -m "Deploy to live  server."


24) Restart Apache

Code:
service httpd restart


25) If you do not use -m for comments, then enter this command if you get the dreaded "svn: None of the environment variables
SVN_EDITOR, VISUAL or EDITOR is set" error.

Code:
EDITOR=vim; export EDITOR


That's all folks!

[ Comments (0) ]


MySQLSoftware.net
2008-04-12 03:51:29 Permalink

Tags: perl software mysql sales


I spent the good part of two days getting mysqlsoftware.net setup on my Linode Fedora 8 VPS. Much work went into server configuration for SSL certification (OpenSSL) and the payment gateway API. When I have some free time I would like to write up a new server prep doc for future reference and for others who may be in need help regrading the same environment setup.

For now, I'll leave this post short. I really need to get back to work on the bulldogracingteam.com Catalyst application.

[stephen]

[ Comments (0) ]


New Blog Up
2008-04-08 17:57:14 Permalink

Tags: catalyst perl blog software developer mvc


Spent a good deal of time today coding my new blog for stephensykes.us. I'll probably drop the old OpenBlog application as it was just a learning project for me when I started working with Catalyst MVC.

And since I need to test the code tag, here's some interesting code for your amusement. This is actually part of the soon to be implemented tag cloud feature for my blog.

Perl Code:
# Update TagCloud weight
foreach my $fields_dbic (
    $c->model('StephenSykesDB::ArticleTags')->search(
        article_id => $form->{article_id},
        {
         prefetch  => 'tag_cloud',
         },
    )
) {
    if ($fields_dbic->tag_cloud->weight > 0) {
        # Subtract 1 from weight and update tag cloud
        my $new_weight = ($fields_dbic->tag_cloud->weight - 1);
        $c->model('StephenSykesDB::TagCloud')->update_or_create({
            tag_id => $fields_dbic->tag_cloud->tag_id,
            descr  => $fields_dbic->tag_cloud->descr,
            weight => $new_weight,
        });
    }
}
# Delete all ArticleTags and then add new from form
$c->model('StephenSykesDB::ArticleTags')->search({ article_id => $form->{article_id} })->delete;
    
# Split tags on white space
my @tags = split(/ /, $form->{Tags});

foreach my $tag_rec (@tags) {
    $tag_rec =~ tr/[A-Z]/[a-z]/;
    my $tag_cloud_dbic = $c->model('StephenSykesDB::TagCloud')->find({ descr => $tag_rec });
    if ($tag_cloud_dbic) { # update existing tag
        my $new_weight = ($tag_cloud_dbic->weight + 1);
        $c->model('StephenSykesDB::TagCloud')->update_or_create({
            tag_id => $tag_cloud_dbic->tag_id,
            descr  => $tag_cloud_dbic->descr,
            weight => $new_weight,
        });
        # Add tags to site_tags table
        $c->model('StephenSykesDB::ArticleTags')->create({
            article_id => $form->{article_id},
            tag_id     => $tag_cloud_dbic->tag_id,
        });
    } else { # create new tag
        $c->model('StephenSykesDB::TagCloud')->create({
            tag_id => undef,
            descr  => $tag_rec,
            weight => '1',
        });
        # Get new tag_id
        my $tag_dbic = $c->model('StephenSykesDB::TagCloud')->find({ descr => $tag_rec });
        # Add tags to site_tags table
        $c->model('StephenSykesDB::ArticleTags')->create({
            article_id => $form->{article_id},
            tag_id     => $tag_dbic->tag_id,
        });
    }
}


[ Comments (0) ]