- Dependencies
- Configuration files - Examples of use (for after)
- Node's global modules
- Node's local modules - Locking versions
- Database - Creating tables and views - Import files from
Before you install OSMBC the following Software has to be installed.
a) Postgres 9.3 or higher
The system is tested and developed under 9.3
, as far as i know all features
used should work with 9.4
. Development is taking place currently with verion 12.
But no special features from versions > 9 are needed
b) Node.JS 14.* or higher
I try to develop OSMBC with a long term node version, do avoid regulary updates
OSMBC puts main configuration in a file with the name config.?.json, where ? can be test or development or production.
The config.test.json is checked in and used in parallel for test on travis-ci server or the local machine. Insofar it is important, to use the same credentials on the local machine, than on travis-ci. Parallel you can create an own config config.testlocal.json and set NODE_ENV to testlocal to use your testfile.
The config.developent.json is not checked in, so it may contain the passwords to your postgres installation, and to the other integrated tools.
The config.production.json should be used for a production environment, so you can have for each usage szenario an own config. config.development.json and config.production.json are listed in .gitignore, so that no passwords are pushed to github.
To generate your first config file, please copy the config.test.json as start.
"serverport": 35043,
"postgres": {
"initialise": true,
"database" : "localhost:5432/osmbc",
"username" : "TheFive",
"password" : "thefive",
"connectstr" : "psql://test:test@localhost:5432/testdb"
},
"twitter":{
"consumer_key": "dummy",
"consumer_secret": "dummy",
"access_token": "dummy",
"access_token_secret": "dummy"
},
"slack":{
"blog":{
"DE":{
"hook":"https://hooks.slack.com/services/blogKey",
"channel":"#osmbcblog"
},
"default":{
"hook":"https://hooks.slack.com/services/blogKeyWeekly",
"channel":"#osmbcblog"
}
},
"article":{
"wn":{
"hook":"https://hooks.slack.com/services/articleKey",
"channel":"#osmbcarticle"
}
}
},
"AppName":"TESTBC",
"languages":["DE","EN","ES"],
"callbackUrl":"http://localhost:3000/auth/openstreetmap/callback",
"OPENSTREETMAP_CONSUMER_KEY" : "######",
"OPENSTREETMAP_CONSUMER_SECRET" : "#####",
"htmlroot":"",
"bootstrap":"http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5",
"EmailSender":"[email protected]",
"url":"https://testosm.bc",
"SMTP":"smtps not defined, as all mails should be mocked by sinon in test",
"sessionStore":"connect-pg-simple"
Where:
-
serverport
is the port in that the node server is listening -
database
is the string of accesse to Postgres -
username
is the username on Postgres -
password
is the password on Postgres -
connectstr
is the string of access to Postgres- Overwrites
database
,username
andpassword
- Overwrites
-
callbackUrl
is the URL of callback for the OAuth mechanism- You must change the serverport
-
OPENSTREETMAP_CONSUMER_KEY
is the OAuth Key- Generate it from your user properties in OSM
-
OPENSTREETMAP_CONSUMER_SECRET
is the OAuth Secret- Generate it from your user properties in OSM
-
htmlroot
is the root for the HTML path to be used to handle multiple instances in a same server- e.g.
MYSERVER/<htmlroot>/osmbc.html
- e.g.
-
slack
There are two slack configurations, the blog and the article configuration.- with the blog configuration you can have a slack hook per language to write
- changes about the blog status (review...) in a separate slack channel for each
- language. Use default for all languages, that should use a common channel.
- the article part allowes to have multiple slack channels to write
- all information about an article to.
- you can get the hook out of your slack integration. Channel is the channel name
- with @ or # as first character
-
twitter
Put in your consumer secrets like offered by twitter.- the twitter API is used to parse the tweets and expand all urls in a tweet.
-
AppName
The name in the upper left corner of the APP and in each mail generated by the App. -
languages
the supported languages. -
bootstrap
root to bootstap, if you do not want to use the one our of the public folder. -
ReviewInWP
deprecated, Review is always started in OSMBC -
EmailSender
define the email adress of all outgoing emails. -
url
the basic url-
- e.g.
url/<htmlroot>/osmbc.html
- e.g.
-
-
smtp
smtp adress (with uername password) to send emails. -
sessionStore
used to configure the session store.- connect-pg-simple is recommended
- session-file-store is an alternative file based NPM Lib.
Please configure your config files package.json
for npm start and npm test.
The config module uses development as default configuration (if it is not set via NODE_ENV
variable).
$ npm start # sets NODE_ENV=development
$ npm test # sets NODE_ENV=test
Please install the following node modules global:
$ sudo npm install istanbul -g # used for Codecoverage during npm test
$ sudo npm install mocha -g # used for tests during npm test
After checkout of OSMBC please install all necessary modules in its directory doing there:
$ npm install
Depending on machine configuration, you may need doing this as root.
Probably you use a NodeJS newer than the supported by OSMBC. Especially if you use a rolling release distribution such as the Arch Linux that today have NodeJS v4.2.1.
The solution for this is using nvm
— Node Version Manager:
- Install the nvm
- On Arch Linux:
$ yaourt -S nvm $ echo 'source /usr/share/nvm/init-nvm.sh' >> ~/.bashrc # if yaourt was ok
- If Ubuntu, see (in portuguese): Como Instalar o Node.js em um Servidor Ubuntu 14.04
- If other distro, see the official instrutions at GitHub creationix/nvm
- If Windows, use nvmw or nvm-windows
- Choose the NodeJS version
- Our develepment machine uses the
0.12.4
$ nvm install 0.12.4
- Our develepment machine uses the
- Choose the Python version
- Switch to 2 at
npm install
if necessary:
$ rm -rf node_modules # take care with the rm -rf $ npm install --python=python2.7 # because I use Python 3 by default
- Switch to 2 at
The database can be installed using the two javascript files that are in the folder import
.
→ See also: section about Configuration files, for database access
NODE_ENV=???? node createdb.js --createTable tablename --verbose
Where ???
is the configuration that you want to use (e.g. development
or test
).
Use createdb.js with the --verbose option, to see the differences between the expected db structure & the real db structure.
(For now there is a more detailed analyses of the indexes, no analyses for the rest).
To create the full database run it with the option --createTable --createIndex --createView, this expects an empty database.
If there are already tables and views you can drop them with --dropTable --dropIndex and --dropView. Please make sure to have a
backup of your productive data, before doing that.
To update to the actual set of indexes just user --updateIndex. (--updateNAME option is for now only available for indexes).
A full working empty copy of OSMBC can be generated with:
NODE_ENV=???? node import/createdb.js --createTables --dropTables --createView --createIndex --addUser OSMUSERNAME --verbose
There is a script to import all the weekly news down from blog.openstreetmap.de.
To import the first blog (the of number 268), call:
NODE_ENV=???? node download.js
For now the first (admin) user has to be created with psql. OSMBC offers only OAUTH authentification via OpenStreetMap, so you have to have a OSM Account and give that user access to your OSMBC instance.
insert into usert (data) values ('{"OSMUser":"?? your osm user name ??","access":"full"}');
But of course it will be better to ask the Weekly - Wochennotiz team, to get a SQL dump.