Skip to content

Commit

Permalink
Jkmarx/pass refinery intro config (#3132)
Browse files Browse the repository at this point in the history
* Add new user config setting for intro paragraph.

* Add intro paragraph to landing page.

* Add markdown library.

* Show intro paragraph.

* Fix unit tests.

* Add unit test.

* Fix duplicate.

* Correct default paragraph.

* Fix another typo.

* Empty string as default.

* Adjust paragraph for clarity.
  • Loading branch information
jkmarx committed Dec 7, 2018
1 parent 83fd78c commit d7ca54b
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 12 deletions.
1 change: 1 addition & 0 deletions deployment/terraform/live/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ module "web" {
refinery_google_analytics_id = "${var.refinery_google_analytics_id}"
refinery_google_recaptcha_site_key = "${var.refinery_google_recaptcha_site_key}"
refinery_google_recaptcha_secret_key = "${var.refinery_google_recaptcha_secret_key}"
refinery_intro = "${var.refinery_intro}"
refinery_s3_user_data = "${var.refinery_s3_user_data}"
refinery_welcome_email_subject = "${var.refinery_welcome_email_subject}"
refinery_welcome_email_message = "${var.refinery_welcome_email_message}"
Expand Down
5 changes: 5 additions & 0 deletions deployment/terraform/live/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ variable "refinery_google_recaptcha_secret_key" {
default = ""
}

variable "refinery_intro" {
description = "Mark-down to be displayed in the intro paragraph on the landing page."
default = "The refinery platform is for managing, analyzing, and visualizing data.\s\s Users can upload various types of files, annotated with pertinent metadata, and can choose to share those files with their own lab and collaborators. Users can also run common analyses via customizable [Galaxy](https://galaxyproject.org/) workflows and explore subsequent results with interactive visualization tools.\s\s Watch feature-specific tutorial videos below to get started. Once you have registered an account, log in, and click [My Dashboard](/dashboard) to start managing your own workspace."
}

variable "refinery_s3_user_data" {
description = "Whether or not to use S3 as user data file storage backend"
default = "false"
Expand Down
1 change: 1 addition & 0 deletions deployment/terraform/modules/ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export FACTER_REFINERY_CUSTOM_NAVBAR_ITEM="${var.refinery_custom_navbar_item}"
export FACTER_REFINERY_GOOGLE_ANALYTICS_ID="${var.refinery_google_analytics_id}"
export FACTER_REFINERY_GOOGLE_RECAPTCHA_SITE_KEY="${var.refinery_google_recaptcha_site_key}"
export FACTER_REFINERY_GOOGLE_RECAPTCHA_SECRET_KEY="${var.refinery_google_recaptcha_secret_key}"
export FACTER_REFINERY_INTRO="${var.refinery_intro}"
export FACTER_REFINERY_S3_USER_DATA="${var.refinery_s3_user_data}"
export FACTER_REFINERY_S3_MEDIA_BUCKET_NAME="${var.media_bucket_name}"
export FACTER_REFINERY_S3_STATIC_BUCKET_NAME="${var.static_bucket_name}"
Expand Down
1 change: 1 addition & 0 deletions deployment/terraform/modules/ec2/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ variable "refinery_custom_navbar_item" {}
variable "refinery_google_analytics_id" {}
variable "refinery_google_recaptcha_site_key" {}
variable "refinery_google_recaptcha_secret_key" {}
variable "refinery_intro" {}
variable "refinery_s3_user_data" {}
variable "refinery_welcome_email_subject" {}
variable "refinery_welcome_email_message" {}
Expand Down
1 change: 1 addition & 0 deletions refinery/config/config.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"REFINERY_GOOGLE_RECAPTCHA_SITE_KEY": "<%= @refinery_google_recaptcha_site_key || "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI" %>",
"REFINERY_GOOGLE_RECAPTCHA_SECRET_KEY": "<%= @refinery_google_recaptcha_secret_key || "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe" %>",
"REFINERY_INNER_NAVBAR_HEIGHT": 20,
"REFINERY_INTRO": "<%= @refinery_intro || "" %>",
"REFINERY_LOG_LEVEL": "DEBUG",
"REFINERY_MAIN_LOGO": "",
"REFINERY_REGISTRATION_CLOSED_MESSAGE": "",
Expand Down
2 changes: 2 additions & 0 deletions refinery/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ def get_setting(name, settings=local_settings, default=None):
# HTML-safe item to be displayed to the right of the `About` link in the navbar
REFINERY_CUSTOM_NAVBAR_ITEM = get_setting("REFINERY_CUSTOM_NAVBAR_ITEM")

REFINERY_INTRO = get_setting("REFINERY_INTRO")

USER_FILES_COLUMNS = get_setting("USER_FILES_COLUMNS")
USER_FILES_FACETS = get_setting("USER_FILES_FACETS")

Expand Down
1 change: 1 addition & 0 deletions refinery/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def extra_context(context):
"MEDIA_BUCKET": settings.MEDIA_BUCKET,
"UPLOAD_BUCKET": settings.UPLOAD_BUCKET,
"REFINERY_DEPLOYMENT_PLATFORM": settings.REFINERY_DEPLOYMENT_PLATFORM,
"REFINERY_INTRO": settings.REFINERY_INTRO,
"USER_FILES_COLUMNS": settings.USER_FILES_COLUMNS,
"REFINERY_GOOGLE_RECAPTCHA_SITE_KEY":
settings.REFINERY_GOOGLE_RECAPTCHA_SITE_KEY,
Expand Down
2 changes: 2 additions & 0 deletions refinery/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
launchpad_tut_viewed: `{{ user.profile.has_viewed_launchpad_tut }}`,
data_upload_tut_viewed: `{{ user.profile.has_viewed_data_upload_tut}}`,
admins: '{{ ADMIN_EMAIL|safe }}',
refineryIntro: '{{ REFINERY_INTRO }}',
repositoryMode: {{ REFINERY_REPOSITORY_MODE|yesno:"true,false,undefined" }},
repositoryModeHomePageHtml: '{{ REFINERY_REPOSITORY_MODE_HOME_PAGE_HTML.strip|safe }}',
solrSynonymSearch: {{ SOLR_SYNONYM_SEARCH|lower }},
Expand Down Expand Up @@ -266,6 +267,7 @@
<script src="{% static "vendor/filesize/lib/filesize.min.js" %}"></script>
<script src="{% static "vendor/lodash/lodash.min.js" %}"></script>
<script src="{% static "vendor/lodash-migrate/dist/lodash-migrate.min.js" %}"></script>
<script src="{% static "vendor/markdown/lib/markdown.js" %}"></script>
<script type="text/javascript">
// Assign lodash v3.9.3 to a special variable so it doesn't conflict with
// lodash v2 or other libraries like underscore.
Expand Down
3 changes: 2 additions & 1 deletion refinery/ui/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"filesize": "3.3.0",
"angular-local-storage": "0.5.2",
"intro.js": "2.4.0",
"angular-intro.js": "2.1.2"
"angular-intro.js": "2.1.2",
"markdown": "0.5.0"
},
"resolutions": {
"d3": "3.5.16",
Expand Down
3 changes: 2 additions & 1 deletion refinery/ui/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
"spark-md5/spark-md5.min.js",
"spectrum/spectrum.js",
"svgxuse/svgxuse.min.js",
"aws-sdk-js/dist/aws-sdk.min.js"
"aws-sdk-js/dist/aws-sdk.min.js",
"markdown/lib/markdown.js"
],
"maps": [
"angular/angular.min.js.map",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
});
}));

it('HomeCtrl ctrl should exist', function () {
it('DataSetChartCtrl ctrl should exist', function () {
expect(ctrl).toBeDefined();
});

Expand Down
28 changes: 28 additions & 0 deletions refinery/ui/source/js/home/ctrls/home-ctrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Home Ctrl
* @namespace HomeCtrl
* @desc Main ctrl for the home view
* @memberOf refineryApp.refineryHome
*/
(function () {
'use strict';
angular
.module('refineryHome')
.controller('HomeCtrl', HomeCtrl);

HomeCtrl.$inject = ['MarkdownJS', '$window'];

function HomeCtrl (MarkdownJS, $window) {
var vm = this;

vm.$onInit = function () {
if ($window.djangoApp && $window.djangoApp.refineryIntro.length) {
var introParagraphs = $window.djangoApp.refineryIntro.split(' ');
vm.htmlIntros = [];
for (var i = 0; i < introParagraphs.length; i++) {
vm.htmlIntros[i] = MarkdownJS.toHTML(introParagraphs[i]);
}
}
};
}
})();
43 changes: 43 additions & 0 deletions refinery/ui/source/js/home/ctrls/home-ctrl.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
(function () {
'use strict';

describe('Controller: Home Ctrl', function () {
var ctrl;
var markdown;
var scope;
var window;

beforeEach(module('refineryApp'));
beforeEach(module('refineryHome'));
beforeEach(inject(function (
$controller,
MarkdownJS,
$rootScope,
$window
) {
scope = $rootScope.$new();
ctrl = $controller('HomeCtrl', {
$scope: scope
});
markdown = MarkdownJS;
window = $window;
window.djangoApp = {
refineryIntro: 'Test text for the refinery intro paragraph. Contact.'
};
}));

it('HomeCtrl ctrl should exist', function () {
expect(ctrl).toBeDefined();
});

it('sets intro paragraph', function () {
ctrl.$onInit();
expect(ctrl.htmlIntros[0]).toEqual(
markdown.toHTML(window.djangoApp.refineryIntro.split(' ')[0])
);
expect(ctrl.htmlIntros[1]).toEqual(
markdown.toHTML(window.djangoApp.refineryIntro.split(' ')[1])
);
});
});
})();
2 changes: 1 addition & 1 deletion refinery/ui/source/js/home/directives/data-set-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
function rpDataSetChart ($window) {
return {
restrict: 'AE',
controller: 'DataSetChartCtrl as $ctrl',
controller: 'DataSetChartCtrl as DSCtrl',
templateUrl: function () {
return $window.getStaticUrl('partials/home/partials/data-set-chart.html');
},
Expand Down
8 changes: 4 additions & 4 deletions refinery/ui/source/js/home/directives/data-set-chart.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@

it('initializes a new Chart class which is an object', function () {
// eslint-disable-next-line no-undef
expect(scope.$ctrl.homeChart).toEqual(jasmine.any(Chart));
expect(scope.DSCtrl.homeChart).toEqual(jasmine.any(Chart));
});

it('initializes a bar chart', function () {
expect(scope.$ctrl.homeChart.config.type).toEqual('bar');
expect(scope.DSCtrl.homeChart.config.type).toEqual('bar');
});

it('sets a hover function', function () {
expect(angular.isFunction(scope.$ctrl.homeChart.config.options.hover.onHover)).toBe(true);
expect(angular.isFunction(scope.DSCtrl.homeChart.config.options.hover.onHover)).toBe(true);
});

it('sets a hover function', function () {
var chartConfig = scope.$ctrl.homeChart.config.options;
var chartConfig = scope.DSCtrl.homeChart.config.options;
expect(angular.isFunction(chartConfig.tooltips.callbacks.label)).toBe(true);
});
});
Expand Down
1 change: 1 addition & 0 deletions refinery/ui/source/js/home/directives/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
angular
.module('refineryHome')
.component('rpHome', {
controller: 'HomeCtrl',
templateUrl: ['$window', function ($window) {
return $window.getStaticUrl('partials/home/views/home.html');
}]
Expand Down
6 changes: 3 additions & 3 deletions refinery/ui/source/js/home/partials/data-set-chart.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<div>
<ui-select
append-to-body="true"
ng-model="$ctrl.selectedAttribute.select"
on-select="$ctrl.updateAttribute($item)"
ng-model="DSCtrl.selectedAttribute.select"
on-select="DSCtrl.updateAttribute($item)"
theme="select2"
class="text-left p-l-1 p-b-1">
<ui-select-match placeholder="Select an attribute">
{{$select.selected.name }}
</ui-select-match>
<ui-select-choices
position="down"
repeat="attribute in $ctrl.attributes | orderBy:'name' track by $index">
repeat="attribute in DSCtrl.attributes | orderBy:'name' track by $index">
<span ng-bind-html="attribute.name"></span>
</ui-select-choices>
</ui-select>
Expand Down
9 changes: 8 additions & 1 deletion refinery/ui/source/js/home/views/home.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<div>
<div class="row p-t-1">
<div class="col-md-4 col-md-offset-7">
<div class="col-md-6">
<ul class="list-unstyled m-l-1-2 p-l-1-3 p-r-1-3">
<li ng-repeat="htmlIntro in $ctrl.htmlIntros">
<p ng-bind-html="htmlIntro"></p>
</li>
</ul>
</div>
<div class="col-md-6">
<rp-data-set-chart></rp-data-set-chart>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions refinery/ui/source/js/refinery-libraries.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ angular
.constant('bootbox', window.bootbox)
.constant('SparkMD5', window.SparkMD5)
.constant('ListGraphVis', window.ListGraph)
.constant('MarkdownJS', window.markdown)
.constant('angular-intro', window['angular-intro']);

0 comments on commit d7ca54b

Please sign in to comment.