Giter Club home page Giter Club logo

magnificent-octopus's Introduction

Magnificent Octopus

Used for building Flask-based applications which may want to talk to an Elasticsearch back-end, and want to integrate with all kinds of external services.

Root Configuration

The root configuration tells Magnificent Octopus where to load the module configurations from, and where to serve Jinja templates and static files from.

It also details scripts to run during application initialisation (i.e. post-configuration but pre-execution). See the section Initialisation below.

The built-in configuration will load the config for all known modules and libraries. You can override this by providing your own one in the environment variable APP_CONFIG at startup.

It provides ONLY the following configuration options:

    # absolute paths, or relative paths from root directory, to the desired config files (in the order you want them loaded)
    CONFIG_FILES = [
        "... lib and module configs ...",
        "config/service.py",
        "local.cfg"
    ]
    
    # absolute paths, or relative paths from root directory, to the template directories (in the order you want them looked at)
    TEMPLATE_PATHS = [
        "service/templates",
        "magnificent-octopus/octopus/templates",
        "... lib and module template directories ...",
        
    ]
    
    # absolute paths, or relative paths from the root directory, to the static file directories (in the order you want them looked at)
    STATIC_PATHS = [
        "service/static",
        "magnificent-octopus/octopus/static",
        "... lib and module static directories ...",
    ]
    
    # module import paths for the startup modules that need to run at application init type (in the order you want them run)
    INITIALISE_MODULES = [
        "octopus.modules.es.initialise"
    ]

Initialisation

After the app has been created and configured, but before it is run, it needs to be initialised. In all scripts and modules which require the application to be in a known fully-operational state, you will need to run the initialise script first.

    from octopus.core import app, initialise
    initialise()

This will load all the modules specified in the INITIALISE_MODULES config in the root configuration (see above). It will then execute their "initialise" function; each module which requires initialisation must provide its own initialisation routine.

To create an initialise routine just supply a function as follows

    from octopus.core import app
    def initialise():
        # do your initialisation operations
        # this function should be idempotent
        pass

Scripts

The octopus /bin directory contains command line scripts that may aid in using/managing an octopus instance.

See the README for more details.

Library code

The octopus.lib directory contains helper libraries for building your applications. See the README for details

Templates

Octopus comes with a basic bootstrap3-based layout template. You should copy the elements you want to modify to your application's template directory, and they will automatically override the octopus ones.

See the templates here

JavaScript

Octopus provides a small library of useful javascript functions. See the README

It also bundles an extensive collection of 3rd party utilities which might be useful for your application, which can be found here

The default _js_includes.html template that comes with octopus already imports the latest version of each of these for convenience, so you could copy that file to your project and add/remove as necessary.

Modules

The following modules are available (follow the links to their README files for more details)

ClientJS

module octopus.modules.clientjs

Used for serving javascript configuration to the client for use by other modules.

CRUD

module octopus.modules.crud

Provides a RESTful CRUD (Create, Retrieve, Update, Delete) API for objects in your application.

DOAJ

module octopus.modules.doaj

Used for providing remote access to the DOAJ search service

EPMC

module: octopus.modules.epmc

Provides a client library for accessing the EuropePMC metadata and fulltexts

Elasticsearch

module: octopus.modules.es

Used for providing direct access to the Elasticsearch back-end:

  • Read-only query endpoint
  • Autocomplete features.
  • Front-end javascript functions for connecting to back-end features.
  • TestCase implementation for setUp and tearDown of test indexes

Examples

module: octopus.modules.examples

Provides working examples of bits of some of the other modules available here

Form

module: octopus.modules.form

Various UI form utilities:

  • A mechanism to bind WTForms forms with context-specific behaviours
  • A UI rendering helper library with support for various Bootstrap form types
  • Custom fields and validators beyond those offered by WTForms
  • Javascript functions to aid in good form building

Identifiers

module: octopus.modules.identifiers

Various tools for working with identifiers

OAG

module: octopus.modules.oag

Client environment for communicating with the Open Article Gauge:

  • Pure client environment
  • Asynchronous job runner for managing large/repeat requests
  • Monitoring interface for job runner

Romeo

module: octopus.modules.romeo

Provides a client library for accessing the Sherpa RoMEO API.

Sherpa Fact

module: octopus.modules.sherpafact

Provides a client library for accessing the Sherpa FACT API.

magnificent-octopus's People

Contributors

richard-jones avatar steven-eardley avatar emanuil-tolev avatar katrinleinweber avatar

Stargazers

wid avatar

Watchers

 avatar  avatar  avatar

magnificent-octopus's Issues

esprit not included

esprit is listed as a project requirement, but is not a submodule or available on pypi. This prevents installing requirements to develop the project in isolation.

DAO query method requires 'query:' in query

Aggregations don't need to be prefixed with a query in es 1.x, but if it's omitted querying via models based on the dao will fail with an exception. My current workaround is to add a match_all query to my aggregation

myquery = {
    "query": { "match_all" : {} },
    "aggregations": {...

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.