Giter VIP home page Giter VIP logo

Comments (4)

Pilzinsel64 avatar Pilzinsel64 commented on May 25, 2024

Maybe this conversation could be relevant here, so linking the issue: #33

from integration_whiteboard.

teutat3s avatar teutat3s commented on May 25, 2024

I managed to get the Nextcloud Spaceboard Integration working manually on arm64.

For the brave:
This assumes you've already downloaded the app through Nextcloud.
Also:
current user: not root (got to use sudo)
web-user = www-data

  1. install node.js 16 + npm
    0.1 (optional: make it work with PHP 8.0)
  2. fixes to compile Node.js sqlite3 native bindings for arm64
# adjust path to your nextcloud apps directory
# this will be our working directory for the next commands
cd /var/www/nextcloud/apps/integration_whiteboard/data/spacedeck

1.1 once in that directory, edit package.json with your favorite terminal editor and paste:

expand package.json file
{
  "name": "spacedeck-open",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "start": "node spacedeck.js",
    "pkg": "pkg -t node10-linux -c package.json -o spacedeck.pkg.bin spacedeck.js",
    "nexe": "nexe -t linux-x64-10.19.0 spacedeck.js -o spacedeck.nexe.bin"
  },
  "engines": {
    "node": ">=10.0.0"
  },
  "pkg": {
    "assets": [
      "views/**/*",
      "public/**/*",
      "locales/*"
    ]
  },
  "dependencies": {
    "archiver": "1.3.0",
    "async": "2.3.0",
    "bcryptjs": "2.4.3",
    "body-parser": "^1.19.0",
    "cheerio": "0.22.0",
    "config": "1.25.1",
    "cookie-parser": "~1.4.3",
    "ejs": "3.1.5",
    "execSync": "latest",
    "express": "^4.16.4",
    "file-type": "^7.6.0",
    "glob": "7.1.1",
    "gm": "^1.23.1",
    "helmet": "^3.5.0",
    "i18n-2": "0.6.3",
    "log-timestamp": "latest",
    "mock-aws-s3": "^2.6.0",
    "moment": "^2.19.3",
    "morgan": "^1.9.1",
    "node-phantom-simple": "2.2.4",
    "node-server-screenshot": "^0.2.1",
    "nodemailer": "^4.6.7",
    "puppeteer": "3.0.0",
    "read-chunk": "^2.1.0",
    "request": "^2.88.0",
    "sanitize-html": "^1.11.1",
    "sequelize": "^4.37.6",
    "serve-favicon": "~2.4.2",
    "serve-static": "^1.13.1",
    "slug": "^1.1.0",
    "sqlite3": "^4.0.0",
    "umzug": "^2.1.0",
    "underscore": "1.8.3",
    "uuid": "^3.2.1",
    "validator": "7.0.0",
    "ws": "3.3.1"
  },
  "devDependencies": {
    "gulp": "^4.0.2",
    "gulp-concat": "^2.6.1",
    "gulp-sass": "^4.0.2"
  },
  "main": "app.js",
  "description": "",
  "directories": {},
  "repository": {
    "type": "git",
    "url": "https://github.com/spacedeck/spacedeck-open.git"
  },
  "keywords": [],
  "author": "Lukas F. Hartmann, Martin Güther",
  "license": "AGPLv3"
}

1.2
patch ./helpers/phantom.js with this patch (extracted from spacedeck/spacedeck-open@26329b0) :

expand patch file
diff --git a/helpers/phantom.js b/helpers/phantom.js
index 197b9a2..5e5e06a 100644
--- a/helpers/phantom.js
+++ b/helpers/phantom.js
@@ -2,7 +2,7 @@

 const db = require('../models/db');
 const config = require('config');
-const phantom = require('node-phantom-simple');
+const puppeteer = require('puppeteer');
 const os = require('os');

 module.exports = {
@@ -25,46 +25,44 @@ module.exports = {

     var on_exit = function(exit_code) {
       if (exit_code>0) {
-        console.error("phantom abnormal exit for url "+space_url);
+        console.error(exit_code);
+        console.error("puppeteer abnormal exit for url "+space_url);
         if (!on_success_called && on_error) {
           on_error();
         }
       }
     };

-    phantom.create({ path: require('phantomjs-prebuilt').path }, function (err, browser) {
-      if (err) {
-        console.error(err);
-      } else {
-        return browser.createPage(function (err, page) {
-          console.log("page created, opening ",space_url);
-
-          if (type=="pdf") {
-            var psz = {
-              width: space.width+"px",
-              height: space.height+"px"
-            };
-            page.set('paperSize', psz);
+    (async () => {
+      let browser;
+      let page;
+      try {
+        browser = await puppeteer.launch(
+          {
+            headless: true,
+            args: ['--disable-dev-shm-usage', '--no-sandbox']
           }
+        );
+        page = await browser.newPage();

-          page.set('settings.resourceTimeout',timeout);
-          page.set('settings.javascriptEnabled',false);
+        page.setDefaultTimeout(timeout);
+        await page.setJavaScriptEnabled(false);

-          return page.open(space_url, function (err,status) {
-            page.render(export_path, function() {
-              on_success_called = true;
-              if (on_success) {
-                on_success(export_path);
-              }
-              page.close();
-              browser.exit();
-            });
-          });
-        });
-      }
+        console.log("page created, opening ",space_url);
+        await page.goto(space_url, {waitUntil: 'networkidle0'});

-    }, {
-      onExit: on_exit
-    });
+        if (type=="pdf") {
+          await page.pdf({path: export_path, width: space.width+'px', height: space.height+'px' });
+        }else{
+          await page.screenshot({path: export_path});
+        }
+
+        await browser.close();
+        on_success(export_path);
+      } catch (error) {
+        on_error();
+      }
+
+    })();
   }
 };

save this as phantomjs.patch, then:

sudo patch ./helpers/phantom.js phantomjs.patch
sudo rm -r node_modules/sqlite3
sudo npm install --build-from-source=sqlite3 --production
  1. use vercel's pkg, not nexe to put it all into one single binary
sudo npm install --global pkg
sudo pkg -c package.json -t linux-node16-arm64 spacedeck.js
sudo chown -R www-data:www-data .
sudo mv spacedeck.nexe.bin spacedeck.nexe.bin.x86_64
sudo mv spacedeck-open spacedeck.nexe.bin
# (re-) enable whiteboard_integration app in nextcloud
# this copies the current folder to `$NC_DATA_DIR/appdata_random-string/spacedeck/`
  1. be happy and use Spacedeck whiteboards

20220206_18h02m21s_grim

from integration_whiteboard.

ProfZiebart avatar ProfZiebart commented on May 25, 2024

@teutat3s,

I try the version without the npm and node update. As far as I see, your patch has an error at line 14.
my patch looks like this:

phantomjs.patch.txt

from integration_whiteboard.

4abhinavjain avatar 4abhinavjain commented on May 25, 2024

Thanks for the effort. I tried the workaround but I get the following error:

patching file ./helpers/phantom.js Hunk #2 FAILED at 25. 1 out of 2 hunks FAILED -- saving rejects to file ./helpers/phantom.js.rej

phantom.js.rej is
--- phantom.js
+++ phantom.js
@@ -25,46 +25,44 @@ module.exports = {

 var on_exit = function(exit_code) {
   if (exit_code>0) {
  •    console.error("phantom abnormal exit for url "+space_url);
    
  •    console.error(exit_code);
    
  •    console.error("puppeteer abnormal exit for url "+space_url);
       if (!on_success_called && on_error) {
         on_error();
       }
     }
    
    };
  • phantom.create({ path: require('phantomjs-prebuilt').path }, function (err, browser) {
  •  if (err) {
    
  •    console.error(err);
    
  •  } else {
    
  •    return browser.createPage(function (err, page) {
    
  •      console.log("page created, opening ",space_url);
    
  •      if (type=="pdf") {
    
  •        var psz = {
    
  •          width: space.width+"px",
    
  •          height: space.height+"px"
    
  •        };
    
  •        page.set('paperSize', psz);
    
  • (async () => {
  •  let browser;
    
  •  let page;
    
  •  try {
    
  •    browser = await puppeteer.launch(
    
  •      {
    
  •        headless: true,
    
  •        args: ['--disable-dev-shm-usage', '--no-sandbox']
         }
    
  •    );
    
  •    page = await browser.newPage();
    
  •      page.set('settings.resourceTimeout',timeout);
    
  •      page.set('settings.javascriptEnabled',false);
    
  •    page.setDefaultTimeout(timeout);
    
  •    await page.setJavaScriptEnabled(false);
    

from integration_whiteboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.