Skip to content

Commit

Permalink
Restructure locations to put plugins under packages dir as per https:…
Browse files Browse the repository at this point in the history
…//wiki.civicrm.org/confluence/display/CRMDOC/Javascript+Reference#JavascriptReference-Location

Add script to fetch latest package files
Update plugins to latest versions
  • Loading branch information
aydun committed Jun 14, 2017
1 parent cabcdfd commit 8be67a2
Show file tree
Hide file tree
Showing 21 changed files with 86 additions and 561 deletions.
16 changes: 8 additions & 8 deletions activityreport.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ function activityreport_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
function activityreport_civicrm_pageRun($page) {
if ($page instanceof CRM_Activityreport_Page_ActivityReport) {
CRM_Core_Resources::singleton()
->addScriptFile('uk.co.compucorp.civicrm.activityreport', 'js/pivottable/pivot.min.js', 0, 'html-header')
->addScriptFile('uk.co.compucorp.civicrm.activityreport', 'js/pivottable/d3.min.js', 0, 'html-header')
->addScriptFile('uk.co.compucorp.civicrm.activityreport', 'js/pivottable/c3.min.js', 0, 'html-header')
->addScriptFile('uk.co.compucorp.civicrm.activityreport', 'js/pivottable/c3_renderers.js', 1, 'html-header')
->addScriptFile('uk.co.compucorp.civicrm.activityreport', 'js/pivottable/export_renderers.js', 1, 'html-header');
->addScriptFile('uk.co.compucorp.civicrm.activityreport', 'packages/d3/d3.min.js', 1, 'html-header')
->addScriptFile('uk.co.compucorp.civicrm.activityreport', 'packages/c3/c3.min.js', 1, 'html-header')
->addScriptFile('uk.co.compucorp.civicrm.activityreport', 'packages/pivottable/pivot.min.js', 1, 'html-header')
->addScriptFile('uk.co.compucorp.civicrm.activityreport', 'packages/pivottable/c3_renderers.min.js', 2, 'html-header')
->addScriptFile('uk.co.compucorp.civicrm.activityreport', 'packages/pivottable/export_renderers.min.js', 2, 'html-header');
CRM_Core_Resources::singleton()
->addStyleFile('uk.co.compucorp.civicrm.activityreport', 'css/pivottable/pivot.css')
->addStyleFile('uk.co.compucorp.civicrm.activityreport', 'css/pivottable/c3.min.css')
->addStyleFile('uk.co.compucorp.civicrm.activityreport', 'css/style.css');
->addStyleFile('uk.co.compucorp.civicrm.activityreport', 'packages/c3/c3.min.css', 1)
->addStyleFile('uk.co.compucorp.civicrm.activityreport', 'packages/pivottable/pivot.min.css', 2)
->addStyleFile('uk.co.compucorp.civicrm.activityreport', 'css/style.css', 3);
}
}

Expand Down
51 changes: 51 additions & 0 deletions bin/fetch_packages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env php
<?php

# Fetch package files

$packages = array (
'd3' => array (
'd3.min.js',
),
'c3' => array (
'c3.min.js',
'c3.min.css',
),
'pivottable' => array (
'c3_renderers.min.js',
'd3_renderers.min.js',
'export_renderers.min.js',
'pivot.min.js',
'pivot.min.css',
),
);

$package_dir = "packages";
if (!is_dir($package_dir)) {
mkdir($package_dir, 0775);
}

foreach ($packages as $key => $files) {
$dir = "$package_dir/$key";
$version_file = "$dir/version";
if (!is_dir($dir)) {
mkdir($dir, 0775, true);
}
$json = file_get_contents("http://api.cdnjs.com/libraries/$key?fields=version,name,filename");
$info = json_decode($json, true);
$version = $info['version'];

if (is_file($version_file) AND is_readable($version_file)) {
$old_json = file_get_contents($version_file);
if ($old_json == $json) {
print "$key is already at latest version: $version\n";
continue;
}
}

file_put_contents($version_file, $json);
print "Downloading $key $version\n";
foreach ($files as $file) {
file_put_contents("$dir/$file", fopen("https://cdnjs.cloudflare.com/ajax/libs/$key/$version/$file", 'r'));
}
}
1 change: 0 additions & 1 deletion css/pivottable/c3.min.css

This file was deleted.

204 changes: 0 additions & 204 deletions css/pivottable/pivot.css

This file was deleted.

5 changes: 5 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ th.pvtAxisLabel, th.pvtRowLabel, th.pvtColLabel {
select.pvtAggregator {
width: 100%;
}

.pvtHorizList li {
display: inline-block;
}

5 changes: 0 additions & 5 deletions js/pivottable/c3.min.js

This file was deleted.

Loading

0 comments on commit 8be67a2

Please sign in to comment.