ryanlelek / Raneto

Markdown powered Knowledgebase Wiki for Node.js
https://raneto.com
MIT License
2.79k stars 446 forks source link

Help with initial configuration #271

Open philipstratford opened 6 years ago

philipstratford commented 6 years ago

Firstly, I think Raneto looks great and is just about the only project I've come across which will (I think!) let me host my application's documentation on an internal company rather than in the cloud, which is a requirement. However, I'm having trouble with some of the initial post-install configuration and can't help thinking that another page in the documentation after "Installing Raneto" would be really useful! Also, the documentation seems to assume good familiarity with node.js, which I do not have. Anyway, my questions are:

  1. I've installed Raneto on a Windows 7 PC which is acting as a server for testing purposes, but I will eventually want to host it on a Windows Server 2012 box. There's no reason why I can't host it this way and make it available within my organisation, is there?
  2. After installing node.js and Raneto, I can see the pages at http://localhost:3000. How do I configure the server so that pages will be served on port 80?

I've read the documentation about this on the "Production Notes" page but I don't understand it. Why is just changing the port env variable to 80 not recommended? Seems much easier than implementing a local reverse proxy and it is a web server, after all - everything else is served on port 80.

The line

You can change the port anytime by setting the environment variable in your shell's profile, or running in-line as below: $ PORT=1234 npm start

means nothing to me. Where is this environment variable? Is it a node thing or a Raneto thing? What is my shell's profile? I'm sure this is basics to someone familiar with node.js, but I'm not.

  1. I can see that all the pages which make up the documentation immediately after install are in the example folder, but if I create a folder alongside example, how do I configure Raneto to load pages from my folder's content sub-folder instead of example's? How do I configure my folder to be the root folder for Raneto's documentation?

  2. There are several references in the documentation to the public folder and it is implied that this folder is created by default, but I can't find this folder anywhere within the Raneto folder. Am I supposed to create it manually? If so, where? There was a note somewhere in the documentation which I now cannot find about why this folder is required to protect files from editing, which I also didn't understand.

Sorry for all the questions and for the fact that this probably isn't the ideal forum for asking them (I did check on StackOverflow first but there's only one question containing the word Raneto). For idiots like me a tutorial for configuring Raneto from installation to a production environment would be really useful. If I ever figure it out I'd be happy to write one - as you can see, I have no problem writing lots of text!

danngyn commented 6 years ago

Somewhat I can answer:

  1. OS shouldn't matter as long as you config your server right. I've never tried Windows but host it on Ubuntu and it works fine. There's a lot of articles showing how to set up node server on Windows.
  2. You can change the port to your preference. This article might help you?
  3. It's all specified in server.js and config.js files of the example/. If you want to run on root folder, make your server.js and config.js on root and point them to ./app/index.js instead of var raneto = require('../app/index.js'). content/ dir is set by default in config.js content_dir
  4. public/ is located inthemes/default/public. You can create your own theme and specify it in config.js under theme_name and public_dir, then it will be themes/[yourthemename]/public.
philipstratford commented 6 years ago

Thanks very much for taking the time, @dkbnguyen. I think my most pressing question at the moment is question 3, but I don't think I get it even after reading your answer. I understand that server.js and config.js are responsible for a lot of the configuration but what tells Raneto to look in the example folder for these files in the first place? For example, if I made a copy of the example folder in the same location and called it example2, how would I tell Raneto to load the config.js and server.js files in THAT folder instead?

danngyn commented 6 years ago

According to this repo setup, the example is the one telling its files (config and server) to look for raneto one level up (parent folder), as you can see here. Therefore it wouldn't make any difference if you make a example2 with the exact same settings.

I feel like this repo setup of example would make new nodejs devs confused. I've made an example of setting up raneto as a dependency using package manager: dkbnguyen/raneto-demo, with clean and structured setup I hope it would help you understand easily. Feel free to ask if you run to any issues.

danngyn commented 6 years ago

Here is another example of running raneto directly: dkbnguyen/Raneto--dev I just simply moved content/ config.js server.js to root folder, changed some *_dir paths in config.js, and finally address the raneto and config vars in server.js. Detailed changes are in commit history.

philipstratford commented 6 years ago

Thanks once again for your help. I don't know if I'm missing a key point (I probably am!), but even with your examples I can't see how node.js knows which instance of Raneto to load. If you created three copies of example in the root Raneto folder, named them example, example1 and example2, then ran Raneto, you'd always get your content at localhost:3000 served from example. I'm trying to figure out how to change that behaviour, and I think I have.

In package.json in the root Raneto directory, lines 32 and 33 contain the path to the server.js file which is loaded when Raneto is started. By altering the path in these lines (only line 33 is relevant to me as I'm running Raneto on a Windows box, but best to change them both) to point to my own subfolder, e.g. example2, and then restarting the application, Raneto is served up from the directory I specify.

I've changed the path in line 37 pointing to my documentation's .js files too.