Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to latest AssetPack #700

Merged
merged 1 commit into from Jun 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -24,3 +24,4 @@ openqa.log
t/data/openqa/factory/hdd/00099963-hdd_image2.qcow2
t/data/openqa/factory/hdd/hdd_image.qcow2
t/diagram-v*.png
assets/cache/
6 changes: 4 additions & 2 deletions Makefile
Expand Up @@ -6,12 +6,14 @@ all:

.PHONY: install
install:
for i in lib public script templates; do \
./script/generate-packed-assets
for i in lib public script templates assets; do \
mkdir -p "$(DESTDIR)"/usr/share/openqa/$$i ;\
cp -a $$i/* "$(DESTDIR)"/usr/share/openqa/$$i ;\
done

# we didn't actually want to install these...
for i in tidy check_coverage; do \
for i in tidy check_coverage generate-packed-assets; do \
rm "$(DESTDIR)"/usr/share/openqa/script/$$i ;\
done
#
Expand Down
561 changes: 561 additions & 0 deletions assets/assetpack.db

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -2,7 +2,7 @@
// only on this file's content
// 20150324-2
@import "bento/bootstrap_variables";
@import "bootstrap";
@import "../cache/raw.githubusercontent.com/twbs/bootstrap-sass/a73cc0f0e5c794206e9a70bc0b67e67cf37c1bca/assets/stylesheets/_bootstrap.scss";
@import "bootstrap_bento";

// Footer overrides for bento compatibility
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions cpanfile
@@ -1,5 +1,6 @@
requires 'Archive::Extract';
requires 'CGI';
requires 'CSS::Minifier::XS', '>= 0.01';
requires 'Cache::Cache';
requires 'Carp';
requires 'Clone';
Expand All @@ -11,10 +12,10 @@ requires 'DBIx::Class';
requires 'DBIx::Class::Core';
requires 'DBIx::Class::DeploymentHandler';
requires 'DBIx::Class::DynamicDefault';
requires 'DBIx::Class::OptimisticLocking';
requires 'DBIx::Class::ResultClass::HashRefInflator';
requires 'DBIx::Class::Schema';
requires 'DBIx::Class::Storage::Statistics';
requires 'DBIx::Class::OptimisticLocking';
requires 'Data::Dump';
requires 'Data::Dumper';
requires 'Data::OptList';
Expand All @@ -37,6 +38,7 @@ requires 'IO::Socket::SSL';
requires 'IPC::Cmd';
requires 'IPC::Run';
requires 'JSON';
requires 'JavaScript::Minifier::XS', '>= 0.11';
requires 'LWP::UserAgent';
requires 'List::MoreUtils';
requires 'MRO::Compat';
Expand All @@ -52,7 +54,7 @@ requires 'Mojo::Util';
requires 'Mojolicious';
requires 'Mojolicious::Commands';
requires 'Mojolicious::Plugin';
requires 'Mojolicious::Plugin::AssetPack', '<= 0.69';
requires 'Mojolicious::Plugin::AssetPack', '>= 1.1';
requires 'Mojolicious::Plugin::Bootstrap3';
requires 'Mojolicious::Static';
requires 'Net::DBus';
Expand All @@ -62,15 +64,15 @@ requires 'Params::Util';
requires 'Params::Validate';
requires 'Perl::Tidy';
requires 'Regexp::Common';
requires 'SQL::Translator';
requires 'SQL::SplitStatement';
requires 'SQL::Translator';
requires 'Scalar::Util';
requires 'Selenium::Remote::Driver';
requires 'Sub::Install';
requires 'Sub::Name';
requires 'Test::Compile';
requires 'Test::Mojo';
requires 'Test::More';
requires 'Test::Compile';
requires 'Text::Markdown';
requires 'Time::HiRes';
requires 'URI::Escape';
Expand Down
99 changes: 44 additions & 55 deletions lib/OpenQA/WebAPI.pm
Expand Up @@ -229,7 +229,7 @@ sub startup {

unshift @{$self->renderer->paths}, '/etc/openqa/templates';

$self->plugin('AssetPack');
$self->plugin(AssetPack => {pipes => [qw(Sass Css JavaScript Combine Fetch)]});
$self->plugin('OpenQA::WebAPI::Plugin::Helpers');
$self->plugin('OpenQA::WebAPI::Plugin::CSRF');
$self->plugin('OpenQA::WebAPI::Plugin::REST');
Expand All @@ -249,62 +249,51 @@ sub startup {
}
}

$self->plugin(bootstrap3 => {css => [], js => []});

$self->asset(
'step_edit.js' => qw(/javascripts/needleedit.js
/javascripts/needleeditor.js
/javascripts/shapes.js
/javascripts/keyevent.js/)
$self->asset->process(
'step_edit.js' => qw(javascripts/needleedit.js
javascripts/needleeditor.js
javascripts/shapes.js
javascripts/keyevent.js/)
);

my @js = qw(/javascripts/jquery-1.11.2.js
/javascripts/jquery_ujs.js
/javascripts/chosen.jquery.js
/javascripts/openqa.js
/javascripts/jquery.dataTables.js
/javascripts/admintable.js
/javascripts/admin_user.js
/javascripts/admin_needle.js
/javascripts/audit_log.js
/javascripts/jquery.timeago.js
/javascripts/tests.js
/javascripts/assets.js
/javascripts/job_templates.js
/javascripts/overview.js
/javascripts/comments.js);
my @css = qw(/stylesheets/font-awesome.css
/stylesheets/chosen.css
/stylesheets/overview.scss
/stylesheets/comments.css
/stylesheets/openqa.css );

# preprocessors to expend the url() definitions in the css
$self->asset->preprocessors->add(
css => sub {
my ($assetpack, $text, $file) = @_;
$$text =~ s!url\('!url('../images/!g if $file =~ /chosen.css/;
});

$self->asset('app.css' => (qw(/stylesheets/jquery.dataTables.css /stylesheets/tables.css), @css));
$self->asset('app.js' => @js);
my $path = Mojolicious::Plugin::Bootstrap3->asset_path('sass');
$ENV{SASS_PATH} = ".:$path";
$self->asset(
'bootstrap.css' => (
qw(/sass/bentostrap.scss
/stylesheets/dataTables.bootstrap.css
), @css
));
$self->asset(
'bootstrap.js' => (
@js, qw(/js/bootstrap/collapse.js
/js/bootstrap/tooltip.js
/js/bootstrap/tab.js
/js/bootstrap/bootstrap.js
/js/bootstrap/transition.js
/javascripts/dataTables.bootstrap.js)
));
my @js = qw(http://code.jquery.com/jquery-1.11.2.js
javascripts/jquery_ujs.js
javascripts/chosen.jquery.js
javascripts/openqa.js
javascripts/jquery.dataTables.js
javascripts/admintable.js
javascripts/admin_user.js
javascripts/admin_needle.js
javascripts/audit_log.js
javascripts/jquery.timeago.js
javascripts/tests.js
javascripts/assets.js
javascripts/job_templates.js
javascripts/overview.js
javascripts/comments.js);
my @css = qw(https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css
stylesheets/chosen.css
stylesheets/overview.scss
stylesheets/comments.css
stylesheets/openqa.css );

# preprocessors to expend the url() definitions in the css - TODO: reenable chosen in job group

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could write a small pipe yourself for this. Have a look at https://metacpan.org/pod/Mojolicious::Plugin::AssetPack::Pipe#Write-a-custom-pipe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I've already seen that documentation. But as we don't use this plugin atm, it's work for later

# $self->asset->preprocessors->add(
# css => sub {
# my ($assetpack, $text, $file) = @_;
# $$text =~ s!url\('!url('../images/!g if $file =~ /chosen.css/;
# });

my $bootstrap_url = "https://raw.githubusercontent.com/twbs/bootstrap-sass/a73cc0f0e5c794206e9a70bc0b67e67cf37c1bca/assets";
$self->asset->process('app.css' => (qw(stylesheets/jquery.dataTables.css stylesheets/tables.css), @css));
$self->asset->process('app.js' => @js);
$self->asset->process('bootstrap.css' => ("$bootstrap_url/stylesheets/_bootstrap.scss", "sass/bentostrap.scss", "stylesheets/dataTables.bootstrap.css", @css));
$self->asset->process('codemirror.css' => qw(stylesheets/codemirror.css));
$self->asset->process('codemirror.js' => qw(javascripts/lib/codemirror.js javascripts/mode/perl/perl.js));
$self->asset->process('needlediff.js' => qw(javascripts/needlediff.js));
$self->asset->process('running.js' => qw(javascripts/running.js));
$self->asset->process('bootstrap.js' => (@js, ("$bootstrap_url/javascripts/bootstrap/collapse.js", "$bootstrap_url/javascripts/bootstrap/tooltip.js", "$bootstrap_url/javascripts/bootstrap/tab.js", "$bootstrap_url/javascripts/bootstrap.js", "$bootstrap_url/javascripts/bootstrap/transition.js", "javascripts/dataTables.bootstrap.js")));
$self->asset->store;

# set secure flag on cookies of https connections
$self->hook(
Expand Down
1 change: 1 addition & 0 deletions profiles/apparmor.d/usr.share.openqa.script.openqa
Expand Up @@ -27,6 +27,7 @@
/usr/share/openqa/dbicdh/** r,
/usr/share/openqa/lib/** r,
/usr/share/openqa/public/** r,
/usr/share/openqa/assets/** r,
/usr/share/openqa/script/openqa r,
/usr/share/openqa/templates/ r,
/usr/share/openqa/templates/** r,
Expand Down
1 change: 1 addition & 0 deletions public/asset/images
Binary file removed public/fonts/FontAwesome.otf
Binary file not shown.
Binary file removed public/fonts/fontawesome-webfont.eot
Binary file not shown.