castor-core

CastorJS the Document Management System

CastorJS the Document Management System

High configurable web server for documents files

Each castor instance has a configuration (either in a file, either in parameters, like when using castor-cli).

See castor-cli.

The configuration object has first level keys, but also further level ones. General configuration has first-level keys.

Site title. The title key is present for each page (although depending on themes too). Optional

Ex:

{
  "title": "First study"
}

Site description. The description key is present for of each page (although depending on themes too). Optional

Ex:

{
  "description": "My First study is cool"
}

The of the MongoDb collection. Default value: a hash of the data path. Optional

Useful to quickly find the right collection in mongo.

Ex:

{
  "collectionName": "first_study"
}

The connection string to mongo.

Default value: mongodb://localhost:27017/castor/

Ex:

{
  "connexionURI": "mongodb://localhost:27017/test/"
}

The port of web server.

Default value: first free port beginning with 3000.

Ex:

{
  "port": 8080
}

The number of items returned in a query.

Default value: 30.

Ex:

{
  "itemsPerPage": 5
}

Each HTML page of a theme,can have a title and a description (see default layout.html).

A theme is free to use them as it wants.

To modify the title or the description of a page, you have to know the identifier of the page.

Typically, a page identifier is the first part of a .html file in a theme (e.g.: index, browse, display, ...).

Default values are empty ones.

Example for castor-theme-sbadmin:

{
  "pages": {
    "index" : {
      "title"       : "Dashboard",
      "description" : "Dashboard of the first study"
    },
    "chart" : {
      "title"       : "Graph",
      "description" : "First study's details"
    },
    "documents" : {
      "title"       : "Documents",
      "description" : "First study's documents"
    }
  }
}

See ezvis.

Add specific route.

Ex :

  1. modify index.js in the theme:
{
  "routes": {
      "/fake" : "fake.js"
  }
}
  1. create a file ./routes/fake.js in the theme:
module.exports = function(config) {
  return function (reqresnext) {
    res.status(200).send('Fake').end();
  };
};

To swith to debug mode

Default value: false

Ex:

{
  "debug": true
}

Choose the log format for STDIN. see Morgan Predefined formats

Default value: combined

Ex:

{
  "logFormat": "dev"
}

Markdown options. see Marked Options

Default value: undefined

Ex:

{
  "markdown": {
         gfm: true,
         tables: true,
         breaks: false,
         pendantic: false,
         sanitize: true,
         smartLists: true,
         smartypants: false
  }
}

FIXME

Default value: default

Ex:

{
  "theme": "my-theme"
}

FIXME

Ex:

{
  "middlewares": {}
}

FIXME

Ex:

{
  "asynchronousFilters": {}
}

FIXME

Ex:

{
  "operators": {}
}

FIXME

Ex:

{
  "loaders": {}
}

FIXME

Ex:

{
  "browserifyModules": {}
}

FIXME Default value: CPUs number

Ex:

{
  "concurrency": 8
}

FIXME

Default value: 250

Ex:

{
  "delay": 1000
}

FIXME

Default value: 128mb

Ex:

{
  "maxFileSize": "1gb"
}

FIXME

Default value: 5000

Ex:

{
  "heartrate": 1800000
}

FIXME

Default value: false

Ex:

{
  "turnoffAll": true
}

FIXME

Default value: false

Ex:

{
  "turnoffSync": true
}

FIXME

Default value: false

Ex:

{
  "turnoffPrimus": true
}

FIXME

Default value: false

Ex:

{
  "turnoffRoutes": "false"
}

FIXME

Default value: false

Ex:

{
  "turnoffIndexes": "false"
}

FIXME

Default value: false

Ex:

{
  "turnoffWebdav": true
}

FIXME

Default value: false

Ex:

{
  "turnoffComputer": true
}

FIXME

Default value: false

Ex:

{
  "turnoffUpload": true
}

FIXME

Default value: [ "**/.*", "~*", "*~", "*.sw?", "*.old", "*.bak", "**/node_modules", "Thumbs.db" ]

Ex:

{
  "filesToIgnore": [ "**/*.txt"]
}

FIXME

Default value: OS default temp directory

Ex:

{
  "tempPath": "/tmp"
}

``documentFields` are fields of documents, that are not parts of the input document, but computed when loading.

They use JBJ syntax to add fields to the document, computed from the current document.

``corpusFieldsare fields computed from the whole corpus, like the number of records, the period it covers (fromyear` document field, for example), etc.

They are computed when the corpus is finished loading. Like documentFields, they use JBJ syntax.

Ex:

{
  "corpusFields": {
    "$recordNb": {
      "$?": "local:///compute.json?operator=count&field=wid",
      "parseJSON": true,
      "get": "data.0.value",
      "cast": "number"
    }
  }
}

Add a new filter to your theme :

  1. Create a 'filters' folder in your theme directory

  2. Add your_filter_name.js to your theme's filters folder

  3. Call the filter in your instance.json config file:

"filters" : {
    "your_filter_file_name" : "your_filter_name",
    "another_filter_file_name" : "another_filter_name"
  }

List & how to use castor's filters :

  • split(separator) Return an array of X elements divided by separator

  • add2Array(itemToAdd , position) Add an item to an array and return it, If no position , push will be the method used

  • objectPath(path) get a deep property of the object, using dot notation. see objectPath.get in object-path.