GithubHelp home page GithubHelp logo

microsoft / duck Goto Github PK

View Code? Open in Web Editor NEW
5.0 9.0 13.0 5.71 MB

Web-based tool to author and check ISO 19944-style data use statements

License: Other

Go 43.86% JavaScript 31.53% HTML 18.15% SCSS 6.46%

duck's Introduction

DUCK Application

Attention: These are Instructions for Developers. If you just want to try DUCK, you might want to download it here. A user manual can be found here, the DUCK architecture is described here.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

This is a Gulp-powered build system with the following features:

  • Sass compilation and prefixing
  • JavaScript transpilation based on Babel and concatenation
  • Go compilation
  • Dynamic browser reloading using BrowserSync
  • For production builds:
    • CSS compression
    • JavaScript compression
    • Image compression

Installation

The project build requires:

  • Git
  • Go (1.7 or later)
  • NodeJS (0.12 or greater, LTS version >4.0.0 recommended)
  • CouchDB (1.6 or greater)

Setup

First clone the project repository. Make sure it is under the GOPATH directory, for example if your GOPATH is:

/gocode

DUCK should be checked out to:

/gocode/src/github.com/Microsoft/DUCK

To clone the codebase, use:

git clone https://github.com/Microsoft/DUCK DUCK

Then, from the cloned directory, install the required dependencies:

cd DUCK
npm install
npm install -g bower
npm install -g gulp
bower install

Make sure Couch DB is running.

Finally, run npm start to execute the build. The application will be accessible at:

http://localhost:8000

Dynamic reloading will be enabled. Both frontend (Javascript, CSS, HTML) and backend (go) assets are watched for changes, which will automatically trigger an application update.

To create compressed, production-ready assets, run npm run build.

Building a Distrubution

Execute the distribution build using:

npm run distro

A binary archive will be generated in the /image directory

Configuration

This project reads its configuration from the file backend/configuration.json, environment variables and also command-line flags. The following precendence order is used. Each item takes precedence over the item below it:

  • flag
  • env
  • config
  • default

Default

The default configuration has these values:

  database: 
      location: "http://127.0.0.1"
      port: 5984
      name: "duck"
	  username: ""
	  password: ""
  jwtkey: "c2VjcmV0"
  webdir: "/src/github.com/Microsoft/DUCK/frontend/dist"
  rulebasedir: "/src/github.com/Microsoft/DUCK/RuleBases"
jwtkey

The field jwtkey is a base64 encoded string. If this field is empty, a random key will be generated.

regarding path variables

If rulebasedir or webdir have an absolute path it is used as an absolute path. If it is a relative path it will be assumed to be relative to the GOPATH environment variable if present. If GOPATH is not found, the path is assumed to be relative to the go executable.

env

The environment variable names are prefixed with DUCK_ and all uppercase. Fields in the database object are referenced using the . operator, e.g. DUCK_DATABASE.NAME.

flags

The flags are handled in the go standard way described in https://golang.org/pkg/flag/. Main points are:

Command line flag syntax:

-flag -flag=x -flag x // non-boolean flags only

>One or two minus signs may be used; they are equivalent. The last form is not permitted for boolean flags because the meaning of the command
>
>`cmd -x *`
>
>will change if there is a file called 0, false, etc. You must use the -flag=false form to turn off a boolean flag.
>
>Integer flags accept 1234, 0664, 0x1234 and may be negative. Boolean flags may be:
>
>`1, 0, t, f, T, F, true, false, TRUE, FALSE, True, False`

It is *not* possible to configure the database connection via flags.

duck's People

Contributors

babakjah avatar cueneythizli avatar jimmarino avatar kant avatar microsoft-github-policy-service[bot] avatar torjas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

duck's Issues

adding new data categories

it should be possible to add new data categories.
addition should be restricted to be leaves in the current data hirarchy (see 19944 latest version)

Database Plugin API

From @jimmarino on June 8, 2016 20:31

The database plugin interface should take and return typed objects such as Document as opposed to byte[]. It may be necessary to add CRUD operations for each type. This will also require de/serialization to be done in the handler layer, which is a good separation and will also assist with being able to implement the URI structure of the REST API. For example, we want to be able to POST or PUT a document using a URI such as:

/v1/documents/

and not have to include the document id as a URL parameter. If the handler deserializes the Document, it will have access to the id.

Also, passing types to the plugin interface will shorten the number of parameters and make the types a database must support explicit

Copied from original issue: Metaform/duck#23

File Download/Upload

Implement the file download feature.

We need to discuss what document formats will be supported.

Frontend seems to have problem with updating revision number

steps to reproduce:

  1. Load document
  2. create & edit statement statement
  3. save statement (The revision # is submitted to the server, a new one is returned in the updated document
  4. repeat 3+4 (no revision number is sent to the server, saving fails silently)

Add server configuration

From @Torjas on June 2, 2016 10:23

Let the server knwo eg how to connect to the DB via a config file
-db connection
-jwt secret

Copied from original issue: Metaform/duck#11

Comply with Microsoft REST guidelines

  • POST operations SHOULD support the Location response header to specify the location of any created resource that was not explicitly named, via the Location header.
  • The error response MUST be a single JSON object. This object MUST have a name/value pair named "error." The value MUST be a JSON object.
    This object MUST contain name/value pairs with the names "code" and "message," and it MAY contain name/value pairs with the names "target," "details" and "innererror."
  • paging and filtering document summaries

npm crashes on windows when it detects a change in the gocode

When the go code is changed the watch script wants to restart the main.exe but only tries to exit the go.exe which was used to build and start the program(main.exe). It then crashes and stops everything except the main.exe which I then have to exit manually.

npm output:

`> [email protected] start c:\Users\tja\Documents\Programming\Go\workspace\src\github.com\Microsoft\DUCK

gulp
[11:16:28] Failed to load external module babel-register
[11:16:28] Requiring external module babel-core/register
[11:16:38] Using gulpfile c:\Users\tja\Documents\Programming\Go\workspace\src\github.com\Microsoft\DUCK\gulpfile.babel.js
[11:16:38] Starting 'default'...
[11:16:38] Starting 'build'...
[11:16:38] Starting 'clean'...
[11:16:38] Finished 'clean' after 5.87 ms
[11:16:38] Starting 'backend'...
[go-run] starting process...
[go-run] [8072] processs started
[11:16:38] Finished 'backend' after 12 ms
[11:16:38] Starting 'pages'...
[11:16:38] Starting 'sass'...
[11:16:38] Starting 'vendorJS'...
[11:16:38] Starting 'javascript'...
[11:16:38] Starting 'images'...
[11:16:38] Starting 'config'...
[11:16:38] Starting 'partials'...
[11:16:38] Starting 'fonts'...
[11:16:38] Starting 'copy'...
[11:16:45] Finished 'partials' after 7.35 s
[11:16:45] Finished 'images' after 7.44 s
[11:16:46] Finished 'config' after 7.68 s
[11:16:46] Finished 'fonts' after 7.77 s
[11:16:46] Finished 'copy' after 7.98 s
[11:16:47] Finished 'pages' after 8.8 s
[11:16:47] Finished 'javascript' after 9.28 s
2016/06/13 11:16:47 Couchase initialization
2016/06/13 11:16:48 Testextension initialized
[11:16:50] Finished 'sass' after 12 s
[11:16:50] Finished 'vendorJS' after 12 s
[11:16:50] Finished 'build' after 12 s
[11:16:50] Starting 'server'...
[11:16:51] Finished 'server' after 923 ms
[11:16:51] Starting 'watch'...
[BS] Proxying: http://localhost:3000
[BS] Access URLs:

   Local: http://localhost:8000
External: http://10.147.69.175:8000

      UI: http://localhost:3001

UI External: http://10.147.69.175:3001

[... Go server logging ..]
[go-run] [8072] restarting process...
[go-run] [8072] stopping process...
[11:17:55] 'watch' errored after 1.07 min
[11:17:55] Error: spawn ps ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1057:32)
at child_process.js:1151:20
at process._tickDomainCallback (node.js:381:11)
[11:17:55] 'default' errored after 1.28 min
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "start"
npm ERR! node v0.12.13
npm ERR! npm v2.15.0
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: gulp
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'gulp'.
npm ERR! This is most likely a problem with the duck package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! gulp
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs duck
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls duck
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! c:\Users\tja\Documents\Programming\Go\workspace\src\github.com\Microsoft\DUCK\npm-debug.log
`

npm-debug.log:
0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files (x86)\\nodejs\\\\node.exe', 1 verbose cli 'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'start' ] 2 info using [email protected] 3 info using [email protected] 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info prestart [email protected] 6 info start [email protected] 7 verbose unsafe-perm in lifecycle true 8 info [email protected] Failed to exec start script 9 verbose stack Error: [email protected] start:gulp 9 verbose stack Exit status 1 9 verbose stack at EventEmitter.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\lifecycle.js:217:16) 9 verbose stack at EventEmitter.emit (events.js:110:17) 9 verbose stack at ChildProcess.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\spawn.js:24:14) 9 verbose stack at ChildProcess.emit (events.js:110:17) 9 verbose stack at maybeClose (child_process.js:1019:16) 9 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:1091:5) 10 verbose pkgid [email protected] 11 verbose cwd c:\Users\tja\Documents\Programming\Go\workspace\src\github.com\Microsoft\DUCK 12 error Windows_NT 6.1.7601 13 error argv "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" 14 error node v0.12.13 15 error npm v2.15.0 16 error code ELIFECYCLE 17 error [email protected] start:gulp17 error Exit status 1 18 error Failed at the [email protected] start script 'gulp'. 18 error This is most likely a problem with the duck package, 18 error not with npm itself. 18 error Tell the author that this fails on your system: 18 error gulp 18 error You can get information on how to open an issue for this project with: 18 error npm bugs duck 18 error Or if that isn't available, you can get their info via: 18 error 18 error npm owner ls duck 18 error There is likely additional logging output above. 19 verbose exit [ 1, true ]

Support pluralization

From @jimmarino on May 31, 2016 15:40

We need to come up with a scheme to support pluralization of connector words in use statements

Copied from original issue: Metaform/duck#8

Modularize handlers

From @jimmarino on June 8, 2016 20:33

The handlers should probably be organized into separate files by resource type, e.g. Document, User, etc.

Let's discuss later.

Copied from original issue: Metaform/duck#24

Readme

From @Torjas on June 9, 2016 15:35

-[] add Go requirement >1.6(go get ..) dependencies?
-[] add couchbase requirement
-[] add prolog requirement
-[]change nodeJS version requirement

Copied from original issue: Metaform/duck#31

Complete error display

The display of statement errors needs to be completed for all fields and polished both in edit and preview mode

Support document copy on backend

Enable the following:

POST
/v1/documents/copy/f38a69a5c51b45518d67bb0552427937

where the last path is the document id to copy. Return the copied document

Terminology update

current terminology is not up to date wrt the current version of 19944
update is needed

Recommendations to resolve conflicts

From @jimmarino on May 4, 2016 17:19

As an Author I want recommendations for changes on my data use statements to resolve conflicts between my data use statements and the legal model.

Copied from original issue: Metaform/duck#3

Make database errors more explicit

From @jimmarino on June 8, 2016 20:45

We should make Database errors more explicit. For example, instead of returning 404 we should return 409 (Conflict) to the client when there is an update conflict. Other specific errors should also be mapped to HTTP code.

Copied from original issue: Metaform/duck#25

Hash user PWs

From @Torjas on June 6, 2016 16:7

  • Hash user PWs using the go/bcrypt package when new user is created
  • Hash submitted PWs on login and compare to save Hash

Copied from original issue: Metaform/duck#21

Document._rev should not be sent to the client as-is

From @jimmarino on June 8, 2016 20:27

Document should not have a _rev field and instead should be modified to "revision". The mapping from _rev to revision should be handled in the CouchDB plugin. The reason we don't want to propagate _rev is to avoid coupling other subsystems to Couchbase-specific items.

Copied from original issue: Metaform/duck#22

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.