Эх сурвалжийг харах

[sdk] Update SDK app template

* Include ICON by default.
* Fix broken footer reference.
* Create a subnav example.
* Removed unused files.
bc Wong 13 жил өмнө
parent
commit
081d73e

+ 1 - 0
desktop/core/src/desktop/app_template/src/app_name/settings.py

@@ -16,3 +16,4 @@
 DJANGO_APPS = [ "${app_name}" ]
 REQUIRES_HADOOP = False
 MENU_INDEX = 100
+ICON = "/${app_name}/static/art/${app_name}.png"

+ 0 - 37
desktop/core/src/desktop/app_template/src/app_name/static/bootstrap.js

@@ -1,37 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you 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.
-Hue.Desktop.register({
-	${app_name_camel} : {
-		name : '${app_name_spaces}',
-		//autolaunch: "/${app_name}/",
-		css : '/${app_name}/static/css/${app_name}.css',
-		require: [ '${app_name}/${app_name_camel}' ],
-		launch: function(path, options){
-			// application launch code here 
-			// example code below: 
-			return new ${app_name_camel}(path || '/${app_name}/', options);
-		},
-		menu: {
-			id: 'hue-${app_name}-menu',
-			img: {
-				// Replace this with a real icon!
-				// ideally a 55x55 transparent png
-				src: '/${app_name}/static/art/${app_name}.png'
-			}
-		},
-		help: '/help/${app_name}/'
-	}
-});

+ 0 - 49
desktop/core/src/desktop/app_template/src/app_name/static/js/Source/app_name_camel/app_name_camel.js

@@ -1,49 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you 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.
-/*
----
-
-script: ${app_name_camel}.js
-
-description: Defines ${app_name_camel}; a Hue application that extends Hue.JBrowser.
-
-authors:
-- Unknown
-
-requires:
-- JFrame/JFrame.Browser
-
-provides: [${app_name_camel}]
-
-...
-*/
-ART.Sheet.define('window.art.browser.${app_name}', {
-	'min-width': 620
-});
-
-var ${app_name_camel} = new Class({
-
-	Extends: Hue.JBrowser,
-
-	options: {
-		className: 'art browser logo_header ${app_name}'
-	},
-
-	initialize: function(path, options){
-		this.parent(path || '/${app_name}/', options);
-	}
-
-});

+ 0 - 0
desktop/core/src/desktop/app_template/src/app_name/static/js/app_name.js


+ 0 - 5
desktop/core/src/desktop/app_template/src/app_name/static/js/package.yml

@@ -1,5 +0,0 @@
-copyright: Apache License v2.0
-version: 0.1
-description: Unknown
-name: ${app_name}
-sources: [Source/${app_name_camel}/${app_name_camel}.js]

+ 5 - 10
desktop/core/src/desktop/app_template/src/app_name/templates/index.mako

@@ -14,22 +14,17 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ${'<'}%!from desktop.views import commonheader, commonfooter %>
+${'<'}%namespace name="shared" file="shared_components.mako" />
 
 ${'$'}{commonheader("${" ".join(word.capitalize() for word in app_name.split("_"))}", "${app_name}", "100px")}
+${'$'}{shared.menubar(section='mytab')}
 
-${'#'}# use double hashes for a mako template comment
-
-<div class="subnav subnav-fixed">
-	<div class="container-fluid">
-	<ul class="nav nav-pills">
-		<li></li>
-	</ul>
-	</div>
-</div>
+${'#'}# Use double hashes for a mako template comment
+${'#'}# Main body
 
 <div class="container-fluid">
   <h2>${" ".join(word.capitalize() for word in app_name.split("_"))} app is successfully setup!</h2>
   ## Pass through literal $
   <p>It's now ${'$'}{date}.</p>
 </div>
-${'$'}{shared.footer()}
+${'$'}{commonfooter()}

+ 16 - 24
desktop/core/src/desktop/app_template/src/app_name/templates/shared_components.mako

@@ -13,30 +13,22 @@
 ## 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.
-${'<%'}!
-#declare imports here, for example:
-#import datetime
-${'%>'}
 
-${'<%'}!
-import datetime
-from django.template.defaultfilters import urlencode, escape
+${'<%!'}
+def is_selected(section, matcher):
+  if section == matcher:
+    return "active"
+  else:
+    return ""
 ${'%>'}
-${'<%'}def name="header(title='${app_name}', toolbar=True)">
-  <!DOCTYPE html>
-  <html>
-    <head>
-      <title>${'$'}{title}</title>
-    </head>
-    <body>
-      ${'%'} if toolbar:
-      <div class="toolbar">
-        <a href="${'$'}{url('${app_name}.views.index')}"><img src="/${app_name}/static/art/${app_name}.png" class="${app_name}_icon"/></a>
-      </div>
-      ${'%'} endif
-${'<'}/%def>
 
-${'<%'}def name="footer()">
-    </body>
-  </html>
-${'<'}/%def>
+${'<%'}def name="menubar(section='')">
+  <div class="subnav subnav-fixed">
+    <div class="container-fluid">
+      <ul class="nav nav-pills">
+        <li class="${'$'}{is_selected(section, 'mytab')}"><a href="#">Tab 1</a></li>
+        <li class="${'$'}{is_selected(section, 'mytab2')}"><a href="#">Tab 2</a></li>
+      </ul>
+    </div>
+  </div>
+${'</%'}def>

+ 0 - 23
desktop/core/src/desktop/app_template/src/app_name/windmilltests.py

@@ -1,23 +0,0 @@
-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you 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 desktop.lib.windmill_util import logged_in_client
-
-def test_${app_name}():
-  """ launches the default view for ${app_name} """
-  client = logged_in_client()
-  client.click(id='hue-${app_name}-menu')
-  client.waits.forElement(classname='Hue-${app_name.upper()}', timeout='2000')