Skip to content

Commit

Permalink
fixed some errors, added to the boot of master node, interface starts I…
Browse files Browse the repository at this point in the history
  • Loading branch information
dgikiller committed Jul 3, 2014
1 parent 5246a5c commit 05bc9f3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 74 deletions.
9 changes: 5 additions & 4 deletions lib/IntelliHome/IntelliHomeNodeMaster.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require IntelliHome::Interfaces::Terminal;
require IntelliHome::Connector;
require IntelliHome::Config;
require IntelliHome::Workers::Master::RemoteSynth;
require IntelliHome::Workers::Master::WebUI;
require IntelliHome::Workers::Master::RPC;
require IntelliHome::Parser::Base;
require AnyEvent;
Expand All @@ -29,7 +30,7 @@ has 'Output' => (
has 'Remote' => (
is => "rw",
default => sub {
my $self=shift;
my $self = shift;
IntelliHome::Workers::Master::RemoteSynth->new(
Config => $self->Config );
}
Expand Down Expand Up @@ -63,7 +64,7 @@ sub update_plugin {

sub start {
my $class = shift;
my $self=__PACKAGE__->instance;
my $self = __PACKAGE__->instance;
my $foreground = shift;
my $IHOutput = $self->Output;
my $Config = $self->Config; #specify where yaml file are
Expand All @@ -80,8 +81,8 @@ sub start {
}
}

my $RPC = IntelliHome::Workers::Master::RPC->new();
$RPC->launch;
IntelliHome::Workers::Master::RPC->new->launch;
IntelliHome::Workers::Master::WebUI->new->launch;

my $me = $self->Remote->Parser->node->selectFromType("master")
; # this for now forces the network to have one master, we can easily rid about that in the future
Expand Down
115 changes: 45 additions & 70 deletions lib/IntelliHome/IntelliHomeWebUI.pm
Original file line number Diff line number Diff line change
@@ -1,124 +1,99 @@
package IntelliHome::IntelliHomeWebUI;


use strict;

use Cwd;

use 5.008_005;

our $VERSION = '0.01';

use Mojo::Base 'Mojolicious';

use Mojo::Loader;

use Mojolicious::Plugin::Disqus::Tiny;

use IO::Compress::Gzip 'gzip';

use Mojolicious::Plugin::BootstrapAlerts;
use Mojolicious::Plugin::AssetPack;
use Mojolicious::Plugin::StaticCompressor;
use Mojolicious::Plugin::Bootstrap3;

sub startup {

my $app = shift;

sub startup {

my $app = shift;
################# Basic plugin loading

$app->plugin('config');

$app->plugin('StaticCompressor');

$app->plugin('AssetPack');

$app->plugin("BootstrapAlerts");

$app->plugin("bootstrap3");


$app->plugin( 'Config' => { file => './config/webui.conf' } );
$app->plugin('StaticCompressor');
$app->plugin('AssetPack');
$app->plugin("BootstrapAlerts");
$app->plugin("bootstrap3");
################# Assets definitions

# script.js and extern.js are bundled in the app.js asset

$app->asset( 'app.js' => '/js/script.js', '/js/extern.js' );
# script.js and extern.js are bundled in the app.js asset

$app->asset( 'style.css' => '/css/style.css' );
$app->asset( 'app.js' => '/js/script.js', '/js/extern.js' );
$app->asset( 'style.css' => '/css/style.css' );

# assets from web

# assets from web

$app->asset(

'web.js' => (

'/js/isotope.pkgd.min.js',

'/js/jquery.infinitescroll.min.js',

'/js/imagesloaded.pkgd.min.js'


)

);

$app->asset(
'web.js' => (
'/js/isotope.pkgd.min.js',
'/js/jquery.infinitescroll.min.js',
'/js/imagesloaded.pkgd.min.js'
)
);

################# Load plugin namespace

push @{ $app->plugins->namespaces }, 'IntelliHome::WebUI::Plugin';
$app->static->paths([cwd().'assets/public']);
$app->renderer->paths([cwd().'assets/templates']);
push @{ $app->plugins->namespaces }, 'IntelliHome::WebUI::Plugin';
$app->static->paths( [ './assets/public' ] );
$app->renderer->paths( [ './assets/templates' ] );

################# GZip Compression

$app->hook(

after_render => sub {

my ( $c, $output, $format ) = @_;

$app->hook(

# Check if "gzip => 1" has been set in the stash
after_render => sub {

return if ( exists $c->stash->{gzip} and $c->stash->{gzip} == 0 );
my ( $c, $output, $format ) = @_;

# Check if "gzip => 1" has been set in the stash

# Check if user agent accepts GZip compression
return if ( exists $c->stash->{gzip} and $c->stash->{gzip} == 0 );

return
# Check if user agent accepts GZip compression

unless ( $c->req->headers->accept_encoding // '' ) =~ /gzip/i;
return

$c->res->headers->append( Vary => 'Accept-Encoding' );
unless ( $c->req->headers->accept_encoding // '' ) =~ /gzip/i;

$c->res->headers->append( Vary => 'Accept-Encoding' );

# Compress content with GZip
# Compress content with GZip

$c->res->headers->content_encoding('gzip');
$c->res->headers->content_encoding('gzip');

gzip $output, \my $compressed;
gzip $output, \my $compressed;

$$output = $compressed;
$$output = $compressed;

}

);
}

);

################# Routes

my $r = $app->routes;

$r->namespaces( ['IntelliHome::WebUI::Controller'] );

my $r = $app->routes;

# Index
$r->namespaces( ['IntelliHome::WebUI::Controller'] );

$r->any('/')->to('index#index');
# Index

$r->any('/index')->to('index#index');
$r->any('/')->to('index#index');

$r->any('/index')->to('index#index');

}

Expand Down

0 comments on commit 05bc9f3

Please sign in to comment.