Code Monkey home page Code Monkey logo

demo-cat's Introduction

Demo Catalog

npm install
bower install
./ml local bootstrap
./ml local deploy modules
./ml local deploy content
gulp

If the app-port specified in build.properties is already occupied and you want to change it for your local environment, do the follow:

  • create and edit deploy/local.properties and set app-port to the port where you want it (you may need to change xcc-port as well)
  • pass --ml-port=???? to the gulp server command. So if you set the port to 8123, run "gulp --ml-port=8123"

Likewise, if you are running MarkLogic on a different host than where you are running the user interface, pass --ml-host to the gulp server command.

Data

You can find the sample data set at ssh.marklogic.com:/home/dcassel/projects/demo-cat/demo-cat.zip. Load it with:

$ ./ml local mlcp import -input_file_path <path to dir with zips or zip itself> -input_compressed –document_type xml

You will need to set the mlcp-home property in your local.properties file for this to work. For instance:

mlcp-home=/Users/dcassel/software/mlcp-Hadoop2-1.2-1

Deployment on server

A local git repo has been setup on the server, add it as a remote to your local git:

Then run the following each time you want to update code on the demo server:

  • git push prod

Ask IT for sudo rights, you might need to chown files to a shared group to have write access.

Once done that, you can run all above deployment steps on the server, just go to /space/projects/demo-cat.live/. A few ml commands might return an error, but only after having done what needed to be done.

Installing as service

The code includes service scripts, and service configs to make installing express server service and gulp watch service as easy as possible. The following files are involved:

  • etc/init.d/node-express-service (generic express server service script)
  • etc/init.d/node-gulp-service (generic gulp watch service script)
  • etc/{env}/conf.sh (env specific service configuration, any env name allowed)
  • startup.js (entry point for express service, calls out to server.js)
  • server.js (called by both gulp server and startup.js)
  • gulpfile.js (entry point for gulp service, which executes default task)

The conf.sh is 'sourced' by the service scripts, and allows overriding the built-in defaults. Usually you only need to override SOURCE_DIR, APP_PORT, and ML_PORT. Make sure they match the appropriate environment.

Next step is to push all source files to the appropriate server. The following assumes it was dropped under /space/projects/ in a folder called demo-cat.live. Take these steps to install the services:

  • cd /etc
  • sudo ln -s /space/projects/demo-cat.live/etc/{env} demo-cat
  • sudo ln -s demo-cat demo-cat-watch
  • cd /etc/init.d
  • sudo ln -s /space/projects/demo-cat.live/etc/init.d/node-express-service demo-cat
  • sudo ln -s /space/projects/demo-cat.live/etc/init.d/node-gulp-service demo-cat-watch
  • sudo chkconfig --add demo-cat
  • sudo chkconfig --add demo-cat-watch
  • sudo chkconfig --levels 2345 demo-cat on
  • sudo chkconfig --levels 2345 demo-cat-watch on

Next to start them, use the following commands (from any directory):

  • sudo service demo-cat start
  • sudo service demo-cat-watch start

These services will also print usage without param, but they support info, restart, start, status, and stop. The info param is very useful to check the settings.

Configuring HTTPS

Easiest way to do this is to configure SSL in httpd. Make sure mod_ssl and openssl are installed:

  • sudo yum install mod_ssl openssl

Then use openssl to generate a key, a CSR (Cert Sign Request), and self-cert the CSR:

  • sudo openssl genrsa -out catalog.key 2048
  • sudo openssl req -new -key catalog.key -out catalog.csr
  • sudo openssl x509 -req -days 365 -in catalog.csr -signkey catalog.key -out catalog.crt

You will need to enter Country, Company, and server name for the CSR. You can also use the CSR to get a Certificate signed by a third party (IT will likely be able to help with that).

Copy the output files in the right location:

  • sudo cp catalog.crt /etc/pki/tls/certs/
  • sudo cp catalog.key /etc/pki/tls/private/
  • sudo cp catalog.csr /etc/pki/tls/private/

Next is configuring httpd. Make sure the ssl.conf points to the correct catalog.key (SSLCertificateKeyFile) and catalog.crt (SSLCertificateFile)

  • sudo vi +/SSLCertificateFile /etc/httpd/conf.d/ssl.conf

You probably also want to unwrap ssl.conf from the

  • sudo vi +/VirtualHost /etc/httpd/conf/httpd.conf

Make sure you have both of these enabled:

NameVirtualHost *:80
NameVirtualHost *:443

And then insert the following at the end:

<VirtualHost *:80>
  ServerName catalog-new.demo.marklogic.com
  Redirect permanent / https://catalog-new.demo.marklogic.com/
</VirtualHost>
<VirtualHost *:443>
  SSLEngine on
  ServerName catalog-new.demo.marklogic.com
  RewriteEngine On
  RewriteCond %{HTTPS} on
  RewriteRule ^(.*)$ http://localhost:4000$1 [P]
</VirtualHost>

You can verify httpd config with:

  • sudo /usr/sbin/httpd -S

For official signing, you need to forward the catalog.csr to IT. They will send two pem files in return: one for the Cert Authority (ca.cert.pem), and a replacement for the catalog.crt file (catalog.demo.cert.pem). Put both in the certs folder, and make sure SSLCertificateFile points to catalog.demo.cert.pem, and SSLCACertificateFile to ca.cert.pem.

Roxy

Roxy (RObust XQuerY Framework) is a lightweight framework for quickly developing well-structured, easily maintained XQuery applications. Roxy was heavily inspired by Ruby On Rails and CakePHP.

Getting Help

To get help with Roxy,

Components

Roxy Deployer

Roxy Deployer makes managing MarkLogic application easy. Simply edit a few configuration files and you have full access to create and deploy applications to MarkLogic servers, local or remote. Roxy Deployer is written in Ruby and is easily extended to add additional functionality.

Roxy mVC

The meat and potatoes of Roxy, the mVC (with a de-emphasis on m) is a light-weight MVC framework fashioned after Ruby on Rails and CakePHP. It relies heavily on Convention over Configuration.

Roxy Unit Tester

What good is your code if it doesn't work? Testing is paramount to the development process. The Roxy Unit Tester tests XQuery with XQuery. Write your tests in XQuery and run them from the UI or from the command line. Roxy Unit Tester produces JUnit XML output so you can use it with your favorite continuous testing tool.

Requirements

  • MarkLogic (notes on supported versions):
    • MarkLogic 4.x - You need the Docs appserver running on port 8000 - this port can be overridden in build.properties
    • MarkLogic 5.x - You need the Manage appserver running on port 8002 - this port can be overridden in build.properties
    • MarkLogic 6.x - You need the Manage appserver running on port 8002 - this port can be overridden in build.properties
  • Ruby 1.9.3+ - Required for Roxy Deployer only.
  • Java (jdk) - Only if you wish to run the Roxy Deployer [XQSync](http://developer.marklogic.com/code/xqsync, XQSync) or RecordLoader commands.
  • Git - Required to create a new project using "ml new".

Getting Started (Quick Version)

This section describes the quickest way to get started using Roxy.

Assumptions

  • You already have one or more MarkLogic Servers running somewhere that you can access from your computer. If not, get it here.*
  • You know the admin logon to your MarkLogic Server(s)

Download Roxy

$ git clone git://github.com/marklogic/roxy.git

Configure your application

  1. Open a command prompt in the root folder of Roxy
  2. Run ml init to create sample configuration files (must specify --server-version option with a value of 4, 5, 6 or 7)
$ ml init app-name --server-version=[version-number]
  1. Modify deploy/build.properties with your application's settings.
# Username to authenticate to ML
user=your-ml-admin-username
# password for ML authentication
password=your-ml-admin-password
# the authentication type for the appserver (digest|basic|application-level)
authentication-method=application-level
# the default user to authenticate with. defaults to nobody
default-user=nobody
# Specify the server(s) you wish to deploy to here. This tutorial assumes you are using localhost.
local-server=localhost
#dev-server=
#cert-server=
#prod-server=

Configure MarkLogic Server

This step is only needed when database configurations have changed or on a fresh install. In most cases you will not need to restart your server.

  1. Open a command prompt in the root folder of Roxy. If your server is not configured as local-server in build.properties then substitute your environment here ( local | dev | prod )
  2. $ ./ml local bootstrap
  3. Depending on what, if anything, you changed you may need to restart MarkLogic in order to proceed. If you see output telling you to restart...
$ ml local restart

Deploying Code

This step describes how to deploy your Roxy application into your MarkLogic Server modules database. If you have elected to run your code locally out of the filesystem you do not need to do this.

  1. Open a command prompt in the root folder of Roxy
  2. $ ml local deploy modules
  3. Open your favorite web browser to http://localhost:port

Sub in your hostname and port from build.properties

Congratulations

Congratulations! You have Roxy running on your server. Now you need to start customizing it.

Getting Help

For more information run: $ ./ml -h

demo-cat's People

Contributors

daveegrant avatar dmcassel avatar grtjn avatar jenbreese avatar joemfb avatar mariannemyers avatar patrickmcelwee avatar paxtonhare avatar ryanjdew avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

demo-cat's Issues

Update README

Only top section is relevant to demo-cat, remainder is about roxy, which is mostly not very relevant.

Some hints about how to add/run tests etc would be nice as well. In the readme or on a wiki page in demo-cat..

Add link editing

Currently, you can't edit the "Hosted at" link or the maintainer's email link. Enhance the editable directive to handle displaying links.

Keep mlRest generic

As (implicitly) suggested in pull request #36, might be a good idea to try to keep mlRest generic, and keep functional meaning in controllers. Makes mlRest much more easy to reuse in different project..

Should be applied to user profile, login, and logout as well. Maybe more? Check logic of controllers. profile, login, and logout are maybe best put in User data service..

Check which users can login..

Deny default-user for starters, and maybe check for rest-writer role presence. Or even better: for the demo-cat-registered-user role..

Add a facet on domain

Needs to be added to create, search, detail, and edit. Initial domain set:

  • DoD
  • Intel
  • PS Civilian
  • PS Healthcare
  • Comm Healthcare
  • FinServ
  • Media

Allow users to type in additional values. A user must be able to select zero or more domains.

Enable RFEs

Users must be able to request new features from a demo's detail page. Record and display what user requested the feature. When the feature request is saved, send an email to the demo's maintainer.

Sign-up feature?

demo-cat users (having demo-cat-registered-role) now have to be created outside demo-cat. A sign-up feature would make that easier..

The application will need one or more application administrators, who can approve people signing up. During registration, collect an email address. Email the application administrator; if approved, send an email to the new user to verify the email address. Include a link that will activate the account. If all that works out, then create a MarkLogic-level user with application-appropriate roles.

Cancel button used by Editable should revert to prior value

On a demo detail, the cancel button simply disables an Editable field. The value in its model has been updated to what the user entered. Cancel should revert back to the prior value. The value in the database is unchanged. A refresh of the page reverts the value back.

Feature filter throws error

http://localhost:9070/v1/search?format=json&options=all&structuredQuery=%7B%22query%22:%7B%22and-query%22:%7B%22queries%22:%5B%7B%22range-constraint-query%22:%7B%22constraint-name%22:%22feature%22,%22value%22:%5B%22Advanced+Search%22%5D%7D%7D,%7B%22range-constraint-query%22:%7B%22constraint-name%22:%22maintainer%22,%22value%22:%5B%5D%7D%7D,%7B%22term-query%22:%7B%22text%22:%22ml%22%7D%7D%5D%7D%7D%7D

returns

<rapi:error xmlns:rapi="http://marklogic.com/rest-api">
rapi:status-code500/rapi:status-code
rapi:statusINTERNAL ERROR/rapi:status
rapi:message-codeXDMP-UNBPRFX/rapi:message-code
rapi:message
XDMP-UNBPRFX: (err:XPST0081) Prefix jbasic has no namespace binding. See the MarkLogic server error log for further detail.
/rapi:message
/rapi:error

Wild guess: is jbasic used in search options perhaps?

Use a CDN

For JavaScript, CSS, and other files available from CDNs, use CDNs to improve load time.

As a user, I want to see a list of tickets assigned to me

Provide a "My Tickets" link next to the Accounts link. Clicking the link will display a view with any tickets (bugs/RFEs) assigned to the current user. The list must include the tickets' title, the project, and the current status.

Allow the user to select which statuses he/she wants to see (multi-select: perhaps a drop-menu with check boxes).

Enable bug reporting

A user must be able to report a bug on a demo. Reporting will be done from the demo's detail page. Record the user who reported the bug. When the bug gets saved, send an email to the demo's maintainer. The form should include:

  • steps to recreate the bug
  • the browser in which the bug was seen

Cleanup the bug list

The bug list for a demo is getting cluttered now that it contains 5 fields. Spruce up the styling to better delineate fields and make it more readable. Update both open and closed bugs.

Features list needs to be dynamic

We started off with a hard-coded list of features, but that needs to be changed such that the list available on the create and edit views get supplemented when users type in new values.

Record supported browsers

Right now the create form shows browsers, but they don't get recorded properly and they can't be edited.

Users should be able to pick from a list of browsers, in order to get canonical forms.

Bug tracking: track assignments

A logged-in user must be able to change who a bug is assigned to. The control for doing so should look like the assignment control on GitHub, providing a text box to search users and a list to select from. The current user is to be at the top of the list, unless that user is filtered out by the current user search.

Email not flushed at logout

Some profile details remain in memory at logout, and appear as profile details of other user at login if that person doesn't have a profile yet.

Improve the affordance of editing

The editable directive allows a user to click on a value, making it switch to an editable form. Improve the affordance by switching to a hover-invitation, showing an edit icon to the right of the field. Clicking the icon will switch to edit mode. Also change the cursor to pointer during hover.

Bug tracking: support changing status

Statuses:

  • open
  • accepted
  • resolved
  • closed

A user must be logged in to change this field. When it is changed, record who changed it, when it was changed, and the start and end statuses as part of the bug history.

Display a project's features

Right now the create page lets you specify a set of features that a demo has. They are recorded correctly in the database, but they aren't displayed on the demo's detail page.

Update the detail page to display the list of features present in the demo.

Changing the status of a bug is broken

Try to close a bug. Error message:

Error: invalid json
    at parse (/space/projects/demo-cat/node_modules/body-parser/index.js:61:15)
    at /space/projects/demo-cat/node_modules/body-parser/index.js:180:18
    at IncomingMessage.onEnd (/space/projects/demo-cat/node_modules/body-parser/node_modules/raw-body/index.js:117:7)
    at IncomingMessage.g (events.js:180:16)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

User info: email

After logging in, the upper-right shows the current user and an Account link. Clicking on the link goes to the /profile page. On the profile page, allow the user to specify one or more email addresses associated with his/her account. A user might have multiple, with one being an individual account and another being a group that the user is a part of.

Enable commenting

Users must be able to leave comments on a demo's detail page. Display most recent comments first. The comment should record who left the comment and when.

Username with hyphen triggers error

On attempting to submit a new user profile, a user with a hyphen in the username will get an error:

SyntaxError: Invalid regular expression: //users/[^(demo-cat-user)]+.json/: Range out of order in character class
  at new RegExp (<anonymous>)
  at Object.handle (/Users/dcassel/git/demo-cat/server.js:177:27)

Need to properly escape hyphens.

Add feature to a demo

On the detail page, most information can be edited by clicking. Add a button to the feature display section that lets a user add a feature. On clicking the button, enable a mode similar to how features are added on the create page, where they can be added from a drop-down or typed in.

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.