diff --git a/openstack_dashboard/contrib/developer/__init__.py b/openstack_dashboard/contrib/developer/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openstack_dashboard/contrib/developer/dashboard.py b/openstack_dashboard/contrib/developer/dashboard.py new file mode 100644 index 000000000..bf1219cbc --- /dev/null +++ b/openstack_dashboard/contrib/developer/dashboard.py @@ -0,0 +1,26 @@ +# Copyright 2015 Cisco Systems, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from django.utils.translation import ugettext_lazy as _ + +import horizon + + +class Developer(horizon.Dashboard): + name = _("Developer") + slug = "developer" + default_panel = "theme_preview" + + +horizon.register(Developer) diff --git a/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.module.js b/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.module.js new file mode 100644 index 000000000..70f532874 --- /dev/null +++ b/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.module.js @@ -0,0 +1,45 @@ +/* + * (c) Copyright 2015 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function () { + 'use strict'; + + /** + * @ngdoc module + * @ngname horizon.dashboard.developer + * @description + * Dashboard module to host developer panels. + */ + angular + .module('horizon.dashboard.developer', [ + 'horizon.dashboard.developer.theme-preview' + ]) + .config(config); + + config.$inject = [ + '$provide', + '$windowProvider' + ]; + + /** + * @name horizon.dashboard.developer.basePath + * @description Base path for the developer dashboard + */ + function config($provide, $windowProvider) { + var path = $windowProvider.$get().STATIC_URL + 'dashboard/developer/'; + $provide.constant('horizon.dashboard.developer.basePath', path); + } +})(); diff --git a/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.module.spec.js b/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.module.spec.js new file mode 100644 index 000000000..b5b9492ac --- /dev/null +++ b/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.module.spec.js @@ -0,0 +1,42 @@ +/* + * (c) Copyright 2015 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +(function () { + 'use strict'; + + describe('horizon.dashboard.developer', function () { + it('should be defined', function () { + expect(angular.module('horizon.dashboard.developer')).toBeDefined(); + }); + }); + + describe('horizon.dashboard.developer.basePath constant', function () { + var developerBasePath, staticUrl; + + beforeEach(module('horizon.dashboard.developer')); + beforeEach(inject(function ($injector) { + developerBasePath = $injector.get('horizon.dashboard.developer.basePath'); + staticUrl = $injector.get('$window').STATIC_URL; + })); + + it('should be defined', function () { + expect(developerBasePath).toBeDefined(); + }); + + it('should equal to "/static/dashboard/developer/"', function () { + expect(developerBasePath).toEqual(staticUrl + 'dashboard/developer/'); + }); + }); +})(); diff --git a/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.scss b/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.scss new file mode 100644 index 000000000..4ad9a92e7 --- /dev/null +++ b/openstack_dashboard/contrib/developer/static/dashboard/developer/developer.scss @@ -0,0 +1,2 @@ +// Top level file for Developer dashboard SCSS +@import "theme-preview/theme-preview"; diff --git a/openstack_dashboard/contrib/developer/static/dashboard/developer/theme-preview/theme-preview.directive.js b/openstack_dashboard/contrib/developer/static/dashboard/developer/theme-preview/theme-preview.directive.js new file mode 100644 index 000000000..926da4afb --- /dev/null +++ b/openstack_dashboard/contrib/developer/static/dashboard/developer/theme-preview/theme-preview.directive.js @@ -0,0 +1,101 @@ +/* + * (c) Copyright 2015 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function() { + 'use strict'; + + angular + .module('horizon.dashboard.developer.theme-preview') + .directive('themepreview', themePreview); + + themePreview.$inject = ['horizon.dashboard.developer.basePath']; + + /** + * @ngdoc directive + * @name themepreview + * @description + * Wraps the JS code for displaying the theme preview page. Shouldnt be used elsewhere. + */ + + function themePreview(path) { + var directive = { + restrict: 'E', + templateUrl: path + 'theme-preview/theme-preview.html', + link: link + }; + + return directive; + } + + function link(scope, element) { + + //TODO(tqtran) Use angular, not jquery + $('a[href="#"]').click(function(e) { + e.preventDefault(); + }); + + var $modal = $('#source-modal'); + var $pre = $modal.find('pre'); + + var $button = $('
') + .click(function(){ + var $fragment = stripAngular($(this).parent().clone()); + var html = cleanSource($fragment.html()); + $pre.text(html); + $modal.modal(); + }); + + var $component = $('.bs-component'); + $component.find('[data-toggle="popover"]').popover(); + $component.find('[data-toggle="tooltip"]').tooltip(); + + $component.hover(function() { + $(this).append($button); + $button.show(); + }); + } + + // Utility function to clean up the source code before displaying + function stripAngular($frag) { + var $translated = $frag.find('[translate]') + .removeAttr('translate'); + $translated.html($translated.find('> span').html()); + $frag.find('.ng-scope').removeClass('ng-scope'); + $frag.find('.ng-pristine').removeClass('ng-pristine'); + $frag.find('.ng-valid').removeClass('ng-valid'); + $frag.find('input').removeAttr('style'); + return $frag; + } + + // Utility function to clean up the source code before displaying + function cleanSource(html) { + var lines = html.split(/\n/); + lines.shift(); + lines.splice(-1, 1); + var indentSize = lines[0].length - lines[0].trim().length; + var re = new RegExp(' {' + indentSize + '}'); + lines = lines.map(function(line) { + if (line.match(re)) { + line = line.substring(indentSize); + } + return line; + }); + lines = lines.join('\n'); + + return lines; + } +})(); + diff --git a/openstack_dashboard/contrib/developer/static/dashboard/developer/theme-preview/theme-preview.html b/openstack_dashboard/contrib/developer/static/dashboard/developer/theme-preview/theme-preview.html new file mode 100644 index 000000000..8523acde4 --- /dev/null +++ b/openstack_dashboard/contrib/developer/static/dashboard/developer/theme-preview/theme-preview.html @@ -0,0 +1,1157 @@ ++ To view source code, hover over a section, then click the button in the top right of that section. +
+ +Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
+Maecenas faucibus mollis interdum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
+This line of text is meant to be treated as fine print.
+The following snippet of text is rendered as bold text.
+The following snippet of text is rendered as italicized text.
+An abbreviation of the word attribute is attr.
+Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.
+Nullam id dolor id nibh ultricies vehicula ut id elit.
+Etiam porta sem malesuada magna mollis euismod.
+Donec ullamcorper nulla non metus auctor fringilla.
+Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
+Maecenas sed diam eget risus varius blandit sit amet non magna.
+++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
+ Someone famous in Source Title +
++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
+ Someone famous in Source Title +
# | +Column heading | +Column heading | +Column heading | +
---|---|---|---|
1 | +Column content | +Column content | +Column content | +
2 | +Column content | +Column content | +Column content | +
3 | +Column content | +Column content | +Column content | +
4 | +Column content | +Column content | +Column content | +
5 | +Column content | +Column content | +Column content | +
6 | +Column content | +Column content | +Column content | +
7 | +Column content | +Column content | +Column content | +
# | +Column heading | +Column heading | +Column heading | +
---|---|---|---|
1 | +Column content | +Column content | +Column content | +
2 | +Column content | +Column content | +Column content | +
Donec ullamcorper nulla non metus auctor fringilla. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
+Curabitur blandit tempus porttitor. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Maecenas faucibus mollis interdum. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Sed posuere consectetur est at lobortis.
+Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Etiam porta sem malesuada magna mollis euismod.
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec id elit non mi porta gravida at eget metus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Sed posuere consectetur est at lobortis.
+Somethings not quite right. Maecenas sed diam eget risus varius blandit sit amet non magna!
+This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.
+ +