Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rudimentary working app
  • Loading branch information
zoffixznet committed Nov 10, 2015
1 parent 666c188 commit e4c1974
Show file tree
Hide file tree
Showing 14 changed files with 245 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Expand Up @@ -8,6 +8,11 @@ Build
web/github-token
web/assets/images/logos
web/assets/css/sprite.css
web/assets/js/jquery.tablesorter.min.js
web/assets/js/jquery.tablesorter.min.js
web/index.html
web/proto.json
mojo-app/public/sass/.sass-cache/
mojo-app/public/sass/cerulean.scss
mojo-app/public/sass/cerulean/
mojo-app/public/packed/
mojo-app/modulesperl6.db
25 changes: 25 additions & 0 deletions mojo-app/Build.PL
@@ -0,0 +1,25 @@
use strict;
use Module::Build;

my $build = Module::Build->new(
dist_name => 'mojo-app::perl6.modules.org',
dist_author => 'Perl 6 Hackers',
license => 'perl',
create_makefile_pl => 'passthrough',

dist_version => '0.1',

# and now the list of perl module dependencies
requires => {
'Mojolicious' => '6.29',
'Mojolicious::Plugin::AssetPack' => '0.68',
'Mojolicious::Plugin::Bootstrap3' => '3.3505',
'Package::Alias' => '0.13',
'SQL::Translator' => '0.11021',
'DBIx::Class' => '0.082820',
'Test::Mojo::WithRoles' => '0.02',
'Test::Mojo::Role::ElementCounter' => '1.001005',
'Test::Mojo::Role::SubmitForm' => '1.001007',
}
);
$build->create_build_script;
7 changes: 7 additions & 0 deletions mojo-app/bin/ModulesPerl6.pl
@@ -0,0 +1,7 @@
#!/usr/bin/env perl

use FindBin;
BEGIN { unshift @INC, "$FindBin::Bin/../lib" }

require Mojolicious::Commands;
Mojolicious::Commands->start_app('ModulesPerl6');
48 changes: 48 additions & 0 deletions mojo-app/lib/ModulesPerl6.pm
@@ -0,0 +1,48 @@
package ModulesPerl6;

# TODO: figure out where to secretly store secrets file on the final server
use constant SECRETS_FILE => '/tmp/secrets';

use Mojo::Base 'Mojolicious';

use Mojo::Util qw/slurp/;
use ModulesPerl6::Model::Dists;

sub startup {
my $self = shift;

# SETUP
$self->config(hypnotoad => {listen => ['http://*:3333']});
$self->moniker('ModulesPerl6');
$self->secrets([
-r SECRETS_FILE ? slurp SECRETS_FILE : 'Perl 6 is awesome!'
]);

# ASSETS
$self->plugin(bootstrap3 =>
theme => { cerulean => 'https://bootswatch.com/cerulean/_bootswatch.scss' }
);
$self->asset('app.css' => '/sass/main.scss');
$self->asset('app.js' => '/js/main.js' );

# HELPERS
$self->helper( dists => sub {
state $dists = ModulesPerl6::Model::Dists->new;
});
$self->helper( items_in => sub {
my ( $c, $what ) = @_;
return unless defined $what;
$what = $c->stash($what) // [] unless ref $what;
return @$what;
});

# ROUTES
my $r = $self->routes;
$r->get('/' )->to('root#index');
$r->get('/q/:term' )->to('root#index');
$r->any('/dist/:dist')->to('root#dist');
}

1;

# ABSTRACT: make dzil happy
10 changes: 10 additions & 0 deletions mojo-app/lib/ModulesPerl6/Controller/Root.pm
@@ -0,0 +1,10 @@
package ModulesPerl6::Controller::Root;

use Mojo::Base 'Mojolicious::Controller';

sub index {
my $self = shift;

$self->stash( dists => $self->dists->find );
}
1;
4 changes: 0 additions & 4 deletions mojo-app/lib/ModulesPerl6/Model/Dists/Schema.pm
Expand Up @@ -5,7 +5,3 @@ use base qw/DBIx::Class::Schema/;
__PACKAGE__->load_namespaces;

1;

__END__

need SQL::Translator >= 0.11018
2 changes: 2 additions & 0 deletions mojo-app/morbo
@@ -0,0 +1,2 @@
#!/bin/sh
morbo -w lib -w bin -w templates -w public -l http://*:3333 bin/ModulesPerl6.pl
Binary file added mojo-app/public/content-pics/camelia-logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added mojo-app/public/js/main.js
Empty file.
Binary file added mojo-app/public/pics/bg.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions mojo-app/public/sass/main.scss
@@ -0,0 +1,42 @@

body {
/* Original vector bg pic is at:
http://zoffix.com/new/modules.perl6.org.bg.eps
*/
background: url(/pics/bg.jpg) no-repeat center top fixed;
background-size: 100% auto;
}

header {
margin-top: 20px;

.panel-body {
/*background: #80B5FF;*/
}

#logo {
margin-top: -60px;
margin-right: -40px;
}
}

@media (max-width: 665px) {
header #logo {
margin: 0;
}
}

.panel h1 {
font-size: 200%;
}

/* Bootstrap amendments */

.btn .glyphicon {
padding-right: .5em;
}

.suckin-btm {
padding-bottom: 5px;
}

5 changes: 5 additions & 0 deletions mojo-app/t/02-app-home-page.t
Expand Up @@ -60,6 +60,11 @@ $_->{travis_url} = Mojo::URL->new($_->{url})->host('travis-ci.org')
$t->dive_reset->get_ok('/')->status_is(200)
->text_is('.count' => 2, 'total distro count is displayed')
;

$t->dive_reset->get_ok('/dist/Dist1')
->status_is(302)
->header_is(Location => 'https://github.com/perl6/modules.perl6.org/')
;
}

done_testing;
41 changes: 41 additions & 0 deletions mojo-app/templates/layouts/default.html.ep
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Perl 6 Modules Directory</title>
<link href="http://perl6.org/favicon.ico" rel="shortcut icon">
%= asset "cerulean.css";
%= asset "app.css";
</head>
<body>
<div class="container">
<%= content %>
<footer class="panel panel-default">
<div class="panel-body suckin-btm">
<p>For feedback and patches, please contact us through the
<a href="https://perl6.org/community/irc">#perl6 IRC
channel</a>, or send an email to the perl6-compiler@perl.org mailing
list.
</p>
<p class="text-muted">
<small>
This page is generated from the files in the
<a href="http://github.com/perl6/modules.perl6.org/"
>modules.perl6.org repository</a>.
<a href="http://modules.perl6.org/log/update.log"
class="btn btn-primary btn-sm">
<i class="glyphicon glyphicon-log-in"></i>
view build log</a>
</small>
</p>
</div>
</footer>
</div>

%= asset "bootstrap.js"
%= asset "app.js";
</body>
</html>
59 changes: 59 additions & 0 deletions mojo-app/templates/root/index.html.ep
@@ -0,0 +1,59 @@
% layout 'default';

<header class="panel panel-primary lead">
<div class="panel-heading">
<h1 class="panel-title">Perl&nbsp;6 Modules</h1>
</div>
<div class="panel-body suckin-btm">
<img src="/content-pics/camelia-logo.png" id="logo" alt="»ö«"
class="pull-right">
<p>Below you can find a list of the 443 known Perl 6 modules. All of them
have been working on <a href="http://rakudo.org/">Rakudo</a> at
some point.
These modules can be installed with <a href="https://github.com/tadzik/panda/">panda</a>, a module management tool
that comes with <a href="http://rakudo.org/how-to-get-rakudo/">Rakudo
Star</a>.
</p>
<p>If you want to contribute your own module, please read
<a href="http://doc.perl6.org/language/modules">this guide</a>.
Missing a module you can't live without? Consider adding it
to the <a href="https://github.com/perl6/perl6-most-wanted/blob/master/most-wanted/modules.md">Most Wanted Modules</a>
file in the Most Wanted repository.
</p>
</div>
</header>

<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">Project List</h2>
</div>
<div class="panel-body table-responsive">
<table class="table table-condensed">
<thead>
<th>Name</th>
<th>Description</th>
<th>Author</th>
<th>Kwalitee</th>
<th>Travis</th>
<th>Stars</th>
<th>Issues</th>
<th>Updated</th>
</thead>
<tbody>
% for my $dist ( items_in 'dists' ) {
<tr>
<td><a href="<%= $dist->{url} %>"><%= $dist->{name} %></a></td>
<td><%= $dist->{description} %></td>
<td><%= $dist->{author_id} %></td>
<td><%= $dist->{kwalitee} %>%</td>
<td class="travis travis-<%= $dist->{travis_status} %>"
><%= $dist->{travis_status} %></td>
<td><%= $dist->{stars} %></td>
<td><%= $dist->{issues} %></td>
<td><%= $dist->{date_updated} %></td>
</tr>
% }
</tbody>
</table>
</div>
</div>

0 comments on commit e4c1974

Please sign in to comment.