Commits

Bob Bergman committed 0978ef0

Simplified/fixed basic ringo coffee template

Comments (0)

Files changed (11)

app/routes.coffee

-module.exports = (app) ->
-
-  app.get "/general", (req, res) ->
-    res.render "general",
-      headers: ({name: k, value: v} for k, v of req.headers)
-      method: req.method
-      scriptName: req.scriptName
-      pathInfo: req.pathInfo
-      queryString: req.queryString
-      host: req.host
-      port: req.port
-      scheme: req.scheme
-      input: req.input

app/server.coffee

-module.exports = require("atlassian/router").createApp("app")
-require("./routes")(module.exports)

app/views/general.mustache.parse

-<!DOCTYPE html>
-<html>
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-    <title>${pluginName}</title>
-    <link rel="stylesheet" href="{{hostStylesheetUrl}}">
-    <link rel="stylesheet" href="public/css/styles.css">
-    <script src="{{hostScriptUrl}}"></script>
-    <script>RA.init();</script>
-  </head>
-  <body>
-    <h2>Request Properties</h2>
-    <table width="100%">
-      <tr>
-        <th align="left" colspan="2">properties</th>
-      </tr>
-      <tr>
-        <td>host base url</td>
-        <td>{{hostBaseUrl}}</td>
-      </tr>
-      <tr>
-        <td>client key</td>
-        <td>{{clientKey}}</td>
-      </tr>
-      <tr>
-        <td>user id</td>
-        <td>{{userId}}</td>
-      </tr>
-      <tr>
-        <td>method</td>
-        <td>{{method}}</td>
-      </tr>
-      <tr>
-        <td>script name</td>
-        <td>{{scriptName}}</td>
-      </tr>
-      <tr>
-        <td>path info</td>
-        <td>{{pathInfo}}</td>
-      </tr>
-      <tr>
-        <td>query string</td>
-        <td>{{queryString}}</td>
-      </tr>
-      <tr>
-        <td>host</td>
-        <td>{{host}}</td>
-      </tr>
-      <tr>
-        <td>port</td>
-        <td>{{port}}</td>
-      </tr>
-      <tr>
-        <td>scheme</td>
-        <td>{{scheme}}</td>
-      </tr>
-      <tr>
-        <th align="left" colspan="2">headers</th>
-      </tr>
-      {{#headers}}
-      <tr>
-        <td>{{name}}</td>
-        <td>{{value}}</td>
-      </tr>
-      {{/headers}}
-    </table>
-    <script src="public/js/client.js"></script>
-  </body>
-</html>

atlassian-plugin.xml.parse

-<?xml version="1.0" ?>
-<atlassian-plugin key="${namespace}.${pluginFolder}" name="${pluginName}" plugins-version="2">
+<?xml version="1.0"?>
+<atlassian-plugin key="${namespace}-${pluginFolder}" name="${pluginName}" plugins-version="2">
 
     <plugin-info>
         <description>${pluginDescription}</description>
         <version>1</version>
     </plugin-info>
 
-    <remote-plugin-container key="container" display-url="http://localhost:8000/${namespace}.${pluginFolder}">
+    <remote-plugin-container key="container" display-url="http://localhost:8000/${namespace}-${pluginFolder}">
     </remote-plugin-container>
 
-    <general-page key="general" name="${pluginName} (general page)" url="/general" />
+    <general-page key="index" name="${pluginName}" url="/index" />
 
 </atlassian-plugin>
-exports.app = require "./app/server"
+app = exports.app = require("atlassian/router").createApp()
+
+app.configure
+  stylesheets: ["app"]
+  scripts: ["app"]
+
+app.get "/index", (req, res) ->
+  res.render "index",
+    message: "Hello World"

public/css/app.css

+#user-id {
+  font-weight: bold;
+}

public/css/styles.css

-/* Application CSS styles go here. */
+AP.getUser(function (user) {
+  document.getElementById("user-id").innerHTML = user.id || "anonymous";
+});

public/js/client.js

-// Application client-side code goes here.
 {
-    "key":"basic"
-    ,"name":"Basic RingoJS Kit"
-    ,"description":"A bare bones ringo-kit template"
-}
+  "key": "basic"
+, "name": "Basic RingoJS Kit"
+, "description": "A bare bones ringo-kit template"
+}

views/index.hbs.parse

+<h1>{{message}}</h1>
+<p>Welcome, <span id="user-id"></span>.</p>