Please advice on how to read variables and values from a Text File

32 views
Skip to first unread message

Dino Lopez

unread,
Apr 22, 2014, 11:01:04 PM4/22/14
to nod...@googlegroups.com
I put a post about something that I see could be a great Web Framework.
https://plus.google.com/106336405206268952858/posts/BRLZB2fZJHT

Basically learning from the success of Cisco and Oracle APEX. what if we have a text file that can build dynamically your web application in NodeJS. pretty cool because you can just copy/pase a simple text file with the simplicity of that and let the framework build the application.

Optionally the data for the site can be included in other data files, the magic of all this is the main file to build the application which can be a simple text file and I'm thinking some CLI shell let you interact and change some of those values, which make the application super easy to manage from the command line. Including changing Layouts/Themes, add regions. automatically generate the navigation and add/remove content.

Yes once build the typical methods like GIT will be able to publish to your preffered site, but the beauty is the magic of just copy/paste a text file and have the assurandce that everything works from there.

My question to the list is what is the best way to store this information. for example:


Version 0.0.1
Site
  title : 'My Site'
  url: 'http://mysite.com'
  webmaster: webm...@mysite.com
  navigation : [ Home, Products, Services, About Us ]
!
Model
!
View
!
Controller
!
Resources
!
end


As you can see the main configuration text file can growth and give all the configuration options to the framework. my question to the list is : What is the best format to put all this information so NodeJS can read it easily and parse it as objects to be able to modify either from a CLI or just read and execute from the shell.

THX Any ideas/suggestions are welcome !!!.






Peter Rust

unread,
Apr 23, 2014, 1:12:45 AM4/23/14
to nod...@googlegroups.com
Dino,

The most common plain-text format for this kind of thing in the npm community is JSON, which has native support via require() and via JSON.parse() / JSON.stringify(). It is used by node's/npm's package.json file.

But there are plenty of people who prefer YAML or other alternatives and plenty of libraries on npm to support reading/writing these formats.

Aside: while it is a great personal exercise to build your own web framework, you won't find a lot of people in the node community jumping at the chance to try something inspired by Cisco or Oracle products. Node is pretty anti-"enterprisey" (see the tongue-in-cheek https://twitter.com/enterprisestack), preferring simpler, small-and-sharp solutions (following the unix philosophy). Node's trademark guardian (and one of its biggest, most active sponsors), Joyent, was founded/birthed in response to Oracle buying the Solaris OS and discontinued open development on it.

-- peter

Dino Lopez

unread,
Apr 23, 2014, 12:13:02 PM4/23/14
to nod...@googlegroups.com
Thank you for your reply Peter, totally appreciate it the honesty.
 
That is exactly what I'm trying to achieve, "simpler, small-and-sharp", also open and super easy to understand and manipulate.
 
Back when I create a super simple Network Monitor [ http://phpopenmonitor.sourceforge.net/ ] even appear on the Linux Journal Magazine around Jun 2000 a simple text file have all the lists of your hosts and the script does the rest.
 
Here is something similar a text file, which as you mention JSON or YAML. maybe for this case seems like JSON is a much better fit will do some tests. I didn't know about Joyent, but will work in some OpenSource Framework that takes the information from a simple Text [ JSON / YAML ] File and build what is necesary from there.
 
Best Regards Dino.
Reply all
Reply to author
Forward
0 new messages