Reveal.js server - serve many presentations - node.js

I'm using markdown and reveal.js to create presentations, and want to start using node.js to serve them from my website.
I've read the docs for reveal.js and it seems like it's easy to do for one presentation, but trickier for several. For example, I'd like
http://mysite/presentations/rabbits
and
http://mysite/presentations/deer
to run on the same instance of node, but each point to a different presetation. Is this possible natively (or with existing plugins), or will I have to hack something together myself?

I know, just three years late. But in case anyone might end up here to look for an answer, there's a working recipe over here: https://web.archive.org/web/20151223044405/https://medium.com/#KienanKB/serving-multiple-reveal-js-presentations-b1a5c086e959 (archived link to the now removed article).
Note: Reveal.js changed the part defining what files it watches:
html: {
 files: [ ‘index.html’ ]
}
Instead of ‘index.html’ it now reads ‘*.html’. 
The recipe still works fine though.

As long as you're using basic features you don't need node.js at all - just drop the reveal.js distribution in every presentation folder where it is served statically.
Another option is hosting on github pages, I've checked it now for this scenario and it seems to be served right.
You might also want to raise this issue at the project page https://github.com/hakimel/reveal.js/issues

Related

I have a GitLab self hosted running, but how does the frontend work?

I set up a GitLab self-hosted instance and its working fine, my problem right now is that I don't really understand how the frontend works. Mostly because I've been focusing on the backend and because I couldn't find documentation about it either. I wish to understand how I can comment out things I don't want to show for the user or in the overall design, change aspects and text, and overall have control of the frontend.
I'm running on Debian 9, the setup was made with Bitnami using Google VM. As far as I understand I have to manually change the files I want, but I really don't understand the structure of this type of frontend.
What language do I need to know here and where should I find the documentation, how to find the correct directory and files, etc.?
While GitLab doesn't officially support any type of "custom frontend", what you can do is:
Fork GitLab
Use the GitLab Development Kit to implement your changes
Run a Source Install of your fork
The frontend is mostly written in HAML (for the server-side bits) and Vue.js (for the client-side bits).
Note: Even an Omnibus install copies raw ruby and javascript files somewhere, and since they’re physically on the system, they can be manually manipulated and hotpatched, but that’s not really a sustainable way of introducing changes to the codebase.

How to build a blog using next.js?

I'm new to web development, recently I want to build my own blog. I use Next.js to host my pages, I have already got the skeleton done, but there are still some significant problems.
How to render pages from markdown file? I just don't know how others do this. Do I have to use fs in the 'server.js' file and respond to certain request by md file? Or there are other ways?
If step 1 was completed, I wonder if I have <img> tags in my markdown file which refer to some local pictures, how can I render those?
To answer 1. You can use the npm package markdown-to-jsx .
But I strongly recommend using Docusorous or GatsbyJS for this purpose. Both have your requirement inbuilt.
Secondly, for Images - You can always include them in Markdown and they will be converted to JSX using markdown-to-jsx .

Basic use of server side API and passing server side variable to client side

I've just started my IT degree and I'm a beginner to the use of APIs (and forums like this) so I am truly sorry if my question is to vaguely explained or if it is just plain stupid :), on top of that I'm not a native English speaker :P. Okay, so I'm trying to use Google trends' api which I installed in my server with putty by using sudo npm install google-trends-api. (it can be found here https://www.npmjs.com/package/google-trends-api#installation) As I undestand it, this is a server side api so the scripts that I write with the methods provided for this api will not run on an explorer as normal js files do. There is an example that makes use of the API that I found on the page which is as follows
var googleTrends = requite('google-trends-api');
googleTrends.hotTrends('US')
.then(function(results){
console.log(results);
})
.catch(function(err){
console.log(err);
});
this outputs a list of 20 items on the console when I use it on node.
I would like to know if there is a way to assign those results to a variable and then use that variable in a normal javascript script inside a html file. I do not know anything about node.js and the like, and I would like to actually do some research instead of asking here but I was going to use a different approach to acquire such information but now I've had to change my plans and do not have enough time and given I consider this is a fairly easy problem to resolve (maybe?) I would really appreciate it if someone could walk me through the basics of each step. THanks :) and have a nice day.
Your question is quite broad. Node.js is Chrome's V8 engine bundled with some libraries to do I/O and networking. This enables us to JavaScript outside of the browser and to create backend services or servers in general (in your case). I hope that you are aware of this difference :)
The first thing that you have to do, is to have a look at express.js and to create a simple server. It will not be more than 20 lines of code. Then you have to enrich this with more stuff like a template engine (handlebars.js, jade etc). You have to enable the server to serve static files that will be finally your js, css and image files. Creating this simple server you will be able to serve simple html page in the first place. On top of that you should have the client side javascript that you have to write and now you can use the module above. Unfortunately, you are not able to use this module directly on a javascript file that you will write. To be able to use this module you have to transcompile this thing into javascript that browser understand*. Remember that browser does not understand the require statement and some old browsers possibly will have issues with the promises that this module is using. These are the things that should be compiled. You have to use a tool like browserify for this and the compiled file that this will extract it must be included in the scripts of your html page.
Maybe there are quite a lot of concepts that you are not aware of or you don't understand them but spend a bit of time to understand them.
P.S.: I' ve replied under the assumption that google-trends-api module does not use things that are specific to node.js like the file-system for example.

Where to put node.js code in cPanel

I am entirely new to backend development so this might be a ridiculously easy and straightforward question, but I'm really not sure. I am trying to learn node.js for backend development, and all of the tutorials I have seen so far show how node can be used to run JavaScript from the terminal and create a server on local host. While this is a neat thing to do, I am stuck there and having difficulty understanding where to put my node.js code on cPanel and how to use it effectively along with the rest of my html/css/js code; all the examples I have seen are very isolated and don't have much interaction with these other files.
Again, I don't have any backend experience, so it would not be very helpful to explain this concept relative to another server-side language like Python, Ruby, or PHP, as I really have no idea where I would put any of the code for any of that stuff either or how it fits into the bigger picture. If the answer could maybe touch on how to integrate Python or PHP as well and general patterns for backend development---the easy stuff everyone assumes but no one explains---it would be much appreciated.
It doesn't matter where you put it. However you probably want to keep it in the folder of the username which is using it. I created a folder called app/ in my users folder and put all my crap in there. Then you simply set it up to listen on a port approved by your host.
You can use a .htaccess file in your public_html folder to redirect to the correct port number.
Your node.js will handle routing. So to go to certain css/html files you will have to set that up in your node.js code.

Orchard Direct Links on Azure

Orchard1.3 installed on Azure. Have built from source
How do I get a nice download link (which doesn't work, but from googling I think should work on single hosted machine) like:
http://www.davemateer.com/media/Default/CodeCamp2012/CodeCampPresentation.zip
instead of this one (which does work)
https://mateerstorage3.blob.core.windows.net/media/Default/CodeCamp2012/CodeCampPresentation.zip
Cheers
Dave
Write a module that exposes its own routes, and proxy the contents through there. It's going to have horrendous performance but it will work.

Resources