Jannick Knudsen пре 1 година
комит
9dd1f36998
14 измењених фајлова са 258 додато и 0 уклоњено
  1. 3 0
      .dockerignore
  2. 9 0
      CHANGELOG
  3. 25 0
      CloudronManifest.json
  4. 1 0
      DESCRIPTION.md
  5. 11 0
      Dockerfile
  6. 21 0
      LICENSE
  7. 1 0
      README.md
  8. 1 0
      bundle
  9. 13 0
      data/config.js
  10. BIN
      logo.png
  11. 12 0
      package.json
  12. 149 0
      server.js
  13. 11 0
      update.sh
  14. 1 0
      webserver

+ 3 - 0
.dockerignore

@@ -0,0 +1,3 @@
+test/*
+.git/*
+

+ 9 - 0
CHANGELOG

@@ -0,0 +1,9 @@
+[0.1.1]
+* Fix path /app/data
+
+
+[0.1.0]
+* Initial version
+
+
+

+ 25 - 0
CloudronManifest.json

@@ -0,0 +1,25 @@
+{
+    "id": "dk.ogi.chatter",
+    "title": "chatter App",
+    "author": "boot",
+    "description": "file://DESCRIPTION.md",
+    "changelog": "./CHANGELOG",
+    "tagline": "Chatter",
+    "version": "0.1.1",
+    "healthCheckPath": "/",
+    "httpPort": 3000,
+    "addons": {
+        "ldap": {},
+        "localstorage": {}
+    },
+    "manifestVersion": 1,
+    "website": "https://ogi.dk",
+    "contactEmail": "boot@ogi.dk",
+    "icon": "logo.png",
+    "tags": [
+        "chatter"
+    ],
+    "mediaLinks": [
+        "https://d.ogi.dk/aaa/az0095.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20170307%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20170307T223156Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=0c07cde39a05dc887fe5e777bfaf17578a5006d14f76996a7685c80d9b0aae7c"
+    ]
+}

+ 1 - 0
DESCRIPTION.md

@@ -0,0 +1 @@
+Please add the appstore description in markdown format here.

+ 11 - 0
Dockerfile

@@ -0,0 +1,11 @@
+FROM cloudron/base:0.10.0
+
+ADD node_modules /app/code/node_modules
+ADD bundle /app/code/bundle
+ADD webserver /app/code/webserver
+ADD server.js /app/code/server.js
+ADD logo.png /app/code/logo.png
+
+
+CMD [ "/usr/local/node-4.7.3/bin/node", "/app/code/server.js" ]
+

+ 21 - 0
LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Cloudron UG
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 1 - 0
README.md

@@ -0,0 +1 @@
+##chatter

+ 1 - 0
bundle

@@ -0,0 +1 @@
+Subproject commit a881f9ce61b5671cf0a569476e243edf49cbfe41

+ 13 - 0
data/config.js

@@ -0,0 +1,13 @@
+//config.js
+/** TWITTER APP CONFIGURATION
+ * consumer_key
+ * consumer_secret
+ * access_token
+ * access_token_secret
+ */
+module.exports = {  
+  consumer_key: 'Nt7OyUmOBniD88RwE3RJ5ogDS',  
+  consumer_secret: 'W184WAmpVk1UebCoD2u5FSdqgrtmW7OvE4V01Bev6SFbfnTKwb',
+  access_token: '2571449886-TEbIpt2n79OAUO70zRztrn2KM7g8qmHMQ7LJp9T',  
+  access_token_secret: 'cJjbJc2bqfCJq5vJ1lOqnlODRFktBLMIPNcB2djKP61JF'
+}


+ 12 - 0
package.json

@@ -0,0 +1,12 @@
+{
+  "name": "chatter",
+  "version": "1.0.0",
+  "description": "",
+  "main": "server.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1",
+    "start": "node server.js"
+  },
+  "author": "",
+  "license": "ISC"
+}

+ 149 - 0
server.js

@@ -0,0 +1,149 @@
+"use strict";
+
+
+var prepath = process.argv[2] === "local" ? process.cwd()+"/data" : "/app/data";
+
+var http = require("http"),
+    url = require("url"),
+    path = require("path"),
+    fs = require("fs"),
+    qs = require("querystring"),
+    port = 3000;
+
+var twit = require("twit");
+
+var config;
+try {
+    config = require(prepath + "/config.js");
+} catch (e) {
+    console.log(prepath + "/config.js not found");
+}
+var server;
+
+var $lib = require("./bundle/bundle.base");
+
+if (config) {
+    var Twitter = new twit(config);
+
+    server = http.createServer(function(req, res) {
+        
+        res.end("TEST");
+
+    })
+
+} else {
+    server = http.createServer(experiment1);
+
+}
+
+
+
+
+
+
+var stream = Twitter.stream('user', {  })
+
+stream.on('message', function (tweet) {
+  console.log(tweet)
+})
+
+
+
+
+server.listen(parseInt(port, 10));
+
+console.log("Static file server running at\n  => http://localhost:" + port + "/\nCTRL + C to shutdown");
+
+
+function experiment1(req, res) {
+
+    var uri = url.parse(req.url).pathname,
+        filename = path.join(prepath, uri);
+
+    if (req.method === "POST") {
+        console.log(req.method, req.body)
+        var body = '';
+
+        req.on('data', function(data) {
+            body += data;
+
+            // Too much POST data, kill the connection!
+            // 1e6 === 1 * Math.pow(10, 6) === 1 * 1000000 ~~~ 1MB
+            if (body.length > 1e6)
+                req.connection.destroy();
+        });
+
+        req.on('end', function() {
+            var post
+            if (body.substring(0, 1) === "{") {
+                try {
+                    post = JSON.parse(body);
+
+                } catch (e) {
+                    post = {
+                        error: e + ""
+                    }
+                }
+
+            } else {
+                post = qs.parse(body);
+
+            }
+            // use post['blah'], etc.
+
+            res.writeHead(200, {
+                "Content-Type": "text/plain"
+            });
+
+            function tweetNow(tweetTxt) {
+                var tweet = {
+                    status: tweetTxt
+                }
+                Twitter.post('statuses/update', tweet, function(err, data, response) {
+                    if (err) {
+                        console.log("Error in Replying");
+                    } else {
+                        console.log("Gratitude shown successfully");
+                    }
+                });
+            }
+
+            tweetNow("Hello World");
+
+            res.write(JSON.stringify(post, true, 2) + "\n");
+            res.end();
+
+
+        });
+        return;
+    }
+
+
+
+    fs.exists(filename, function(exists) {
+        if (!exists) {
+            res.writeHead(404, {
+                "Content-Type": "text/plain"
+            });
+            res.write("404 Not Found\n");
+            res.end();
+            return;
+        }
+        if (fs.statSync(filename).isDirectory()) filename += '/index.html';
+
+        fs.readFile(filename, "binary", function(err, file) {
+            if (err) {
+                res.writeHead(500, {
+                    "Content-Type": "text/plain"
+                });
+                res.write(err + "\n");
+                res.end();
+                return;
+            }
+
+            res.writeHead(200);
+            res.write(file, "binary");
+            res.end();
+        });
+    });
+}

+ 11 - 0
update.sh

@@ -0,0 +1,11 @@
+
+
+sudo docker rm chatter -f
+sudo docker build -t chatter .
+sudo docker run -v /home/jb/repos/cloudron/chatter/data:/app/data -d -p 3001:3000 -p 44010:44009 --name chatter chatter
+
+#curl -H "x-apikey: 153B8BE088000000000C317D406CC194C741136" "https://api.router.iske.dk/add" -d "host=demox.iske.dk&url=http://192.168.1.33:3000"
+
+sudo docker logs chatter -f
+
+

+ 1 - 0
webserver

@@ -0,0 +1 @@
+Subproject commit 730d1180491d903abda2a53a90bc6de2870ce288