Skip to content

Commit

Permalink
retrieve static path info from config
Browse files Browse the repository at this point in the history
  • Loading branch information
orlandov committed Jun 10, 2009
1 parent 63c182b commit a35fb12
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 32 deletions.
14 changes: 14 additions & 0 deletions blogjob.conf
@@ -1,6 +1,12 @@
# rename this file to BlogJob.yml and put a ':' in front of 'name' if
# you want to use YAML like in old versions of Catalyst
name BlogJob
static_url_path = /static

<Session>
flash_to_stash 1
storage /tmp/session_production
</Session>

<Plugin::Authentication>
use_session 1
Expand All @@ -21,3 +27,11 @@ name BlogJob
</store>
</default>
</Plugin::Authentication>

<Model::Posts>
<args>
hostname localhost
port 27017
dbname blogjob_production
</args>
</Model::Posts>
16 changes: 0 additions & 16 deletions lib/BlogJob.pm
Expand Up @@ -12,22 +12,6 @@ use Catalyst qw/-Debug
Static::Simple/;
our $VERSION = '0.01';

__PACKAGE__->config(
name => 'BlogJob',
session => {
flash_to_stash => 1,
storage => '/tmp/session',
}
);

__PACKAGE__->config->{'Model::Posts'} = {
args => {
hostname => 'localhost',
port => 27017,
dbname => 'blogjob'
}
};

__PACKAGE__->setup();

1;
Binary file added lib/BlogJob/Controller/.Posts.pm.swp
Binary file not shown.
Binary file added lib/BlogJob/Controller/.Root.pm.swp
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/BlogJob/Controller/Posts.pm
Expand Up @@ -94,7 +94,7 @@ sub view :Chained('base') PathPart('view') Args {
my ($self, $c, @name) = @_;

my @data = $c->stash->{posts_model}->posts(
query => {
{
canonical_name => join( '/', @name)
}
);
Expand Down
6 changes: 3 additions & 3 deletions lib/BlogJob/Controller/Root.pm
Expand Up @@ -28,9 +28,9 @@ BlogJob::Controller::Root - Root Controller for BlogJob

sub index :Path :Args(0) {
my ( $self, $c ) = @_;

# Hello World
$c->response->body( $c->welcome_message );
return $c->res->redirect(
$c->uri_for(
$c->controller('posts')->action_for('list')));
}

sub default :Path {
Expand Down
Binary file added lib/BlogJob/Model/Backend/.MongoDB.pm.swp
Binary file not shown.
11 changes: 5 additions & 6 deletions lib/BlogJob/Model/Backend/MongoDB.pm
Expand Up @@ -10,8 +10,7 @@ method posts_collection {
return $db->get_collection('posts');
}

method posts {
my ($query) = @_;
method posts($query = {}) {
my @data = $self->posts_collection->query($query)->all;
return
sort { $b->created <=> $a->created }
Expand All @@ -26,10 +25,6 @@ method by_canonical($name) {
);
}

method remove($query) {
$self->posts_collection->remove($query);
}

method add(BlogJob::Model::Backend::MongoDB::Post $post, :$query) {
$self->posts_collection->insert($post->as_hash);
}
Expand All @@ -41,6 +36,10 @@ method update(BlogJob::Model::Backend::MongoDB::Post $post, :$canonical_name) {
);
}

method remove($query) {
$self->posts_collection->remove($query);
}

method remove_all {
$self->posts_collection->remove({});
}
Expand Down
10 changes: 5 additions & 5 deletions root/lib/site/html
Expand Up @@ -3,11 +3,11 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>[% template.title or site.title %]</title>
<link rel="stylesheet" href="[% c.uri_for('/static/') %]css/blueprint/src/reset.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="[% c.uri_for('/static/') %]css/blueprint/screen.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="[% c.uri_for('/static/') %]css/blueprint/src/grid.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="[% c.uri_for('/static/') %]css/blueprint/src/typography.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="[% c.uri_for('/static/') %]css/blueprint/print.css" type="text/css" media="print"/>
<link rel="stylesheet" href="[% c.config.static_url_path %]/css/blueprint/src/reset.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="[% c.config.static_url_path %]/css/blueprint/screen.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="[% c.config.static_url_path %]/css/blueprint/src/grid.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="[% c.config.static_url_path %]/css/blueprint/src/typography.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="[% c.config.static_url_path %]/css/blueprint/print.css" type="text/css" media="print"/>
<link rel="alternate" type="application/atom+xml" title="blog.2wycked.net" href="[% c.uri_for('/posts/feed') %]" />
<!--[if lt IE 8]><link rel="stylesheet" href="css/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->

Expand Down
2 changes: 1 addition & 1 deletion root/lib/site/layout
Expand Up @@ -38,7 +38,7 @@
[%- END %]
</ul>
<hr/>
<a title="Atom" type="application/atom+xml" href="[% c.uri_for('/posts/feed') %]"><img src="[% c.uri_for('/static/') %]/images/feed-icon-14x14.png"/></a>
<a title="Atom" type="application/atom+xml" href="[% c.uri_for('/posts/feed') %]"><img src="[% c.config.static_url_path %]/images/feed-icon-14x14.png"/></a>
</div>
</div>
</div>

0 comments on commit a35fb12

Please sign in to comment.