Git Product home page Git Product logo

Comments (2)

yurenchen000 avatar yurenchen000 commented on September 26, 2024

How to use

didn't create docker image, just copy files to instance:

https://github.com/yurenchen000/hedgedoc/commits/1.9_add_viewjs

1. copy public/viewjs/*

copy them

public/viewjs/
├── viewer.css
├── viewer.js
└── viewer.png

2. patch js

diff for 1.9.2

diff --git a/lib/csp.js b/lib/csp.js
index 82573bea..46e35b8d 100644
--- a/lib/csp.js
+++ b/lib/csp.js
@@ -27,6 +27,11 @@ const defaultDirectives = {
   mediaSrc: ['*']
 }
 
+const viewjsDirectives = {
+  scriptSrc: [config.serverURL + '/viewjs/'],
+  styleSrc: [config.serverURL + '/viewjs/']
+}
+
 const disqusDirectives = {
   scriptSrc: ['https://disqus.com', 'https://*.disqus.com', 'https://*.disquscdn.com'],
   styleSrc: ['https://*.disquscdn.com'],
@@ -53,6 +58,7 @@ const allowPDFEmbedDirectives = {
 CspStrategy.computeDirectives = function () {
   const directives = {}
   mergeDirectives(directives, config.csp.directives)
+  mergeDirectives(directives, viewjsDirectives)
   mergeDirectivesIf(config.csp.addDefaults, directives, defaultDirectives)
   mergeDirectivesIf(config.csp.addDisqus, directives, disqusDirectives)
   mergeDirectivesIf(config.csp.addGoogleAnalytics, directives, googleAnalyticsDirectives)
diff --git a/public/views/hedgedoc.ejs b/public/views/hedgedoc.ejs
index 725e11c8..33c66280 100644
--- a/public/views/hedgedoc.ejs
+++ b/public/views/hedgedoc.ejs
@@ -11,4 +11,10 @@
     <%- include('hedgedoc/footer') %>
 </body>
 
+<!------------- codimd.ejs ----->
+
+<!--- chen added for viewerjs // edit page --->
+<script src="/viewjs/viewer.js"></script>
+<link  href="/viewjs/viewer.css" rel="stylesheet">
+
 </html>
diff --git a/public/views/pretty.ejs b/public/views/pretty.ejs
index 97274ba1..47f56933 100644
--- a/public/views/pretty.ejs
+++ b/public/views/pretty.ejs
@@ -76,3 +76,10 @@
 <script src="<%- serverURL %>/build/MathJax/config/Safe.js" defer></script>
 <%- include('build/pretty-pack-scripts') %>
 <%- include('shared/ga') %>
+
+
+<!------- pretty.ejs ------->
+
+<!--- chen added for viewerjs // view page --->
+<script src="/viewjs/viewer.js"></script>
+<link  href="/viewjs/viewer.css" rel="stylesheet">

from hedgedoc.

yurenchen000 avatar yurenchen000 commented on September 26, 2024

screenshot

codimd_img_viewer.png

from hedgedoc.

Related Issues (1)

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.