Skip to content
Permalink
Browse files

js version

  • Loading branch information...
esokullu committed Jun 16, 2019
1 parent a3639e6 commit 4efb600bf0f1bbb62ac58f0e77892341f7cecfc0
Showing with 2,889 additions and 733 deletions.
  1. +2 −1 .env.example
  2. +3 −2 .gitignore
  3. +4 −4 README.md
  4. +0 −2 bin/.htaccess
  5. +73 −0 bin/generate
  6. +0 −74 bin/generate.php
  7. +0 −9 composer.json
  8. +13 −0 dist/graphjs-theme.less
  9. +0 −4 generate/.htaccess
  10. +70 −0 generate/index.js
  11. +0 −74 generate/index.php
  12. +58 −0 index.js
  13. +0 −29 index.php
  14. +169 −0 lib/FileGeneration.js
  15. +0 −166 lib/FileGeneration.php
  16. +7 −0 lib/asyncMiddleware.js
  17. +35 −0 lib/functions.js
  18. +33 −0 lib/init.js
  19. +0 −32 lib/init.php
  20. +2,162 −0 package-lock.json
  21. +13 −0 package.json
  22. +35 −0 server.js
  23. +9 −0 site/templates/account.njk
  24. +0 −20 site/templates/account.php
  25. +9 −0 site/templates/create-group.njk
  26. +0 −20 site/templates/create-group.php
  27. +8 −20 site/templates/{error.php → error.njk}
  28. +14 −0 site/templates/feed.njk
  29. +0 −25 site/templates/feed.php
  30. +9 −0 site/templates/forum.njk
  31. +0 −20 site/templates/forum.php
  32. +14 −0 site/templates/group.njk
  33. +0 −25 site/templates/group.php
  34. +9 −0 site/templates/groups.njk
  35. +0 −20 site/templates/groups.php
  36. +35 −0 site/templates/home.njk
  37. +0 −47 site/templates/home.php
  38. +30 −24 site/templates/layout/{base.php → base.njk}
  39. +10 −0 site/templates/layout/template_generate.njk
  40. +0 −9 site/templates/layout/template_generate.php
  41. +23 −0 site/templates/layout/template_show.njk
  42. +0 −20 site/templates/layout/template_show.php
  43. +9 −0 site/templates/members.njk
  44. +0 −20 site/templates/members.php
  45. +9 −0 site/templates/messages.njk
  46. +0 −20 site/templates/messages.php
  47. +14 −0 site/templates/profile.njk
  48. +0 −25 site/templates/profile.php
  49. +9 −20 site/templates/{settings.php → settings.njk}
  50. +1 −1 site/vendor/graphjs/graph.js
  51. BIN site/vendor/graphjs/graph.js.gz
@@ -1,2 +1,3 @@
SALT=
BACKUP_SCRIPT=/usr/local/bin/groups-backup.sh
BACKUP_SCRIPT=/usr/local/bin/groups-backup.sh
REDIRECT=
@@ -1,3 +1,4 @@
/node_modules
.env
.DS_Store
composer.lock
/vendor

@@ -1,15 +1,15 @@
## Grou.ps v2

A simple static page generator for Grou.ps v2 sites.
A simple static page generator for Grou.ps v2 sites. Based on https://github.com/phonetworks/grou-ps-v2/releases/tag/php

Please note, this repo covers only the frontend components. For the backend, you need to install [GraphJS-Server](https://github.com/phonetworks/graphjs-server). GraphJS-Server can be run on your own servers, or it can be deployed in one-click to Heroku. For more information, check out [GraphJS-Server README](https://github.com/phonetworks/graphjs-server/blob/master/README.md)

### Installation

For getting started, you just need to install the PHP dependencies using [Composer](https://getcomposer.org/) by typing in:
For getting started, you just need to install the Node dependencies using [NPM](https://www.npmjs.com/get-npm) by typing in:

```sh
composer install
npm install
```


@@ -18,7 +18,7 @@ composer install
To generate a Grou.ps site, type in:

```sh
bin/generate.php {group_name} {public_graphjs_id} {group_title}
bin/generate {group_name} {group_title} --id {public_graphjs_id}
```

where:

This file was deleted.

@@ -0,0 +1,73 @@
#!/usr/bin/env node

const path = require('path');
const cmd = require('commander');
const FileGeneration = require('../lib/FileGeneration');

const dir = path.dirname(__dirname) + '/site/templates';

cmd.description('Generates static social network frontend');
cmd.arguments('<name> <title>', 'Name');
cmd.option('-d, --description, <description>', 'Group Description (may contain spaces or special chars)');
cmd.option('-g, --git, <git>', 'Git Remote Url');
cmd.option('-i, --id, <id>', 'GraphJS ID');
cmd.option('-h, --host, <host>', 'GraphJS Server Hostname');
cmd.option('-s, --stream_host, <stream_host>', 'Stream Server Hostname');
cmd.option('-p, --primary_color, <primary_color>', 'Primary Color');
cmd.option('-t, --text_color, <text_color>', 'Text Color');
cmd.option('-b, --background_color, <background_color>', 'Background Color');
cmd.option('-t, --theme, <theme>', 'Theme (light or dark)');
cmd.option('-m, --modules, <modules>', 'List of extra modules to enable; forum, groups');
cmd.option('-xh, --extra_head, <extra_head>', 'Extra code to inject in HEAD');

let args = [];
let name;
let title;

cmd.action(function (argName, argTitle) {
args = Array.from(arguments);
name = argName;
title = argTitle;
});

cmd.parse(process.argv);

if (args.length === 0) {
console.error('ERROR: <name> and <title> must be specified');
process.exit(1);
}

const publicId = cmd.id || null;
const theme = cmd.theme || 'light';
const textColor = cmd.text_color || null;
const backgroundColor = cmd.background_color || null;
const primaryColor = cmd.primary_color || null;
const host = cmd.host || null;
const streamHost = cmd.stream_host || null;
const description = (cmd.hasOwnProperty('description') && cmd.description) || '';
const remoteUrl = cmd.git || '';
const modules = cmd.modules.split(",") || '';
const extraHead = (cmd.hasOwnProperty('extra_head') && cmd.description) || '';

var moduleForum = "off";
var moduleGroups = "off";

for(let i=0;i<modules.length;i++) {
switch(modules[i].trim()) {
case "forum":
moduleForum = "on";
break;
case "groups":
moduleGroups = "on";
break;
}
}

(new FileGeneration(
dir, name, title, theme, publicId, primaryColor,
textColor, backgroundColor, host, streamHost,
remoteUrl, description, extraHead, moduleForum, moduleGroups
)).generate().catch(function (error) {
console.error(error);
});

This file was deleted.

This file was deleted.

@@ -258,6 +258,19 @@
}
}

.@{prefix}-root {
.@{prefix}-secondary-btn {
color: @text-color-weak;
border-color: @text-color-weak;
background-color: @background-color-shade;
&:hover {
color: @text-color-normal;
border-color: @text-color-normal;
background-color: @background-color-contrast;
}
}
}

//mention-container.less
.@{prefix}-mention-container {
ul {

This file was deleted.

@@ -0,0 +1,70 @@
const path = require('path');
const crypto = require('crypto');
const fs = require('fs');
const executable = require('executable');
const child_process = require('child_process');
const FileGeneration = require('../lib/FileGeneration');
const fn = require('../lib/functions');

module.exports = async function (req, res) {

const rootPath = path.dirname(__dirname);
const dir = rootPath + '/site/templates';
const body = req.body;
const q = req.query;

const name = q.name || body.name || null;
const title = q.title || body.title || null;
const description = q.description || body.description || '';
const remoteUrl = q.git || body.git || '';
const publicId = q.public_id || body.public_id || null;
const theme = q.theme || body.theme || null;
const textColor = q.text_color || body.text_color || null;
const backgroundColor = q.background_color || body.background_color || null;
const primaryColor = q.primary_color || body.primary_color || null;
const host = q.host || body.host || null;
const streamHost = q.stream_host || body.stream_host || null;
const secret = q.secret || body.secret || null;
const regen = q.regen || body.regen || false;
const moduleForum = q.module_forum || body.module_forum || false;
const moduleGroups = q.module_groups || body.module_groups || false;
const extraHead = q.extra_head || body.extra_head || '';

if (! name || ! title || ! publicId) {
res.setHeader('Content-Type', 'application/json');
return res.send(JSON.stringify({
success: false,
message: 'name, title, public_id are required',
}));
}

if (crypto.createHash('md5').update(name + process.env.SALT).digest('hex') != secret) {
res.setHeader('Content-Type', 'application/json');
return res.send(JSON.stringify({
success: false,
message: 'not authorized',
}));
}

const backupScript = process.env.BACKUP_SCRIPT;
if (
backupScript
&& await fn.fs.exists(backupScript)
&& await executable(backupScript)
) {
await fn.child_process.execFile(backupScript);
}

// actual file generation takes place here.
await (new FileGeneration(
dir, name, title, theme, publicId, primaryColor,
textColor, backgroundColor, host, streamHost,
remoteUrl, description, extraHead, moduleForum, moduleGroups
)).generate(regen);

res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify({
success: true,
message: 'Generated',
}));
};

This file was deleted.

0 comments on commit 4efb600

Please sign in to comment.
You can’t perform that action at this time.