API Reference zotonic_core v#1.0.0-rc.17

Modules

The m_acl model gives access the id of the currently logged in user, and provides a mechanism to do basic access control checks.

This model can retrieve information about the resource category hierarchy in different ways.

Zotonic has two places where a site's configuration is kept

Dispatch or generate URLs or page paths. Useful to check dispatch rules or for client side code to dispatch page paths.

Access information about page connections.

The category hierarchy tables have been replaced by m_hierarchy. This model defines named hierarchies of resources (pages).

The m_identity model manages usernames and other user identities. mod_authentication uses it to store and check salted passwords, but also provides a safe storage for user tokens of any kind, as used by mod_facebook.

Access to data about uploaded files and other media.

Access information about which modules are installed and which ones are active.

Retrieve information about predicates. Predicates are the labels on edges (connections between resources) that give meaning to an edge. An example is the predicate "author" which refers to the authors of an article. Predicates form together with the referring and the referred page a triple {subject, predicate, object}.

Model for RDF summaries of resources. It provides short RDF-oriented summary maps for resources, with translated and non-translated variants.

This model gives access to the request variables from within a template.

The main resource model, which is the central part of the Zotonic data model. This model provides an interface to all resource ("page") information. It also provides an easy way to fetch edges from pages without needing to use the m_edge model.

Export a full resource representation for API and model access.

This model tracks deleted resources (see m_rsc). Its primary goal is to be able to determine if a resource never existed, has been deleted or has been replaced by another resource.

Import model for resources exported by m_rsc_export.

Resource update helper module used by m_rsc.

The m_search model provides access to different kinds of search queries for searching through models.

Retrieve information that is stored in the site configuration. If you want to query values from the config table instead, you should use m_config.

Model for dynamic template rendering. It renders a template path passed in the request path and returns the rendered template output.

z

Interfaces for command line utilities in zotonic_launcher, some easy shortcuts and error logging functions.

Access control for Zotonic. Interfaces to modules implementing the ACL events.

Handle authentication of zotonic users. Also shows the logon screen when authentication is required.

Wrapper for Zotonic application environment configuration

Generic support for finding and parsing config files.

Request context for Zotonic request evaluation.

Helper functions commonly used in controllers.

Middleware for cowmachine, extra Context based initializations. This starts the https request processing after the site and dispatch rule have been selected by the z_sites_dispatcher middleware.

Crypto related functions for checksums and signatures.

Parse CSV file into a nested list of lines and fields.

Write data to a CSV file

Installing parts of the zotonic datamodel. Installs predicates, categories and default resources.

Utility functions for datetime handling and representation.

Interface to database, uses database definition from Context.

Postgresql pool worker. Supervises a database connection, ensures it is connected. The connection is given to the query process. If the query process doesn't return the connection, then the connection is reset.

Postgresql zotonic codec

Database pool wrapper. Start and stop database pool workers.

Functions to create, update or drop database tables.

Database pool worker behaviour definition

z_depcache interface file for handing depcache functions from the Zotonic context.

Manage dispatch lists (aka definitions for url patterns). Constructs named urls from dispatch lists.

Simple drop folder handler, monitors a directory and signals new files.

Check for changed edges, trigger notifications.

Send e-mail to a recipient. Optionally queue low priority messages.

Email image embedding

Email server. Queues, renders and sends e-mails.

Execute OS commands with timeouts.

Open a site in Chrome or Chromium.

Exometer reporter which publishes exometer stats to mqtt topics.

Expression parsing and evaluation.

Fetch data from URLs. Interfaces to z_url_fetch and z_url_metadata.

Process holding information mapping a request path to one or more files. The files can be a static file, a temporary file, cached file or a binary.

Locate a file and (if needed) generate a preview. Used by z_file_entry.erl

Keep a registration of file modification times, especially for z_template

Interface to static files and media storage system.

Supervisor for file processes, these processes cache and maintain file information for other file services. They can also resize, combine files and compress files.

Extend the filehandler with mappers for translations, templates and mediaclass.

Convert a html text to markdown syntax. This is used when editing TinyMCE texts with the markdown editor.

Functions supplying random strings, unique ids and nonce support.

Install Zotonic, loads the datamodel into the database Assumes the database has already been created (which normally needs superuser permissions anyway)

Initialize the database with start data.

Reinstall the schema for the given site. The site must have valid configuration to fetch the database configuration. The site will be stopped, the schema dropped and then recreated using the usual installer by restarting the site.

This server will install the database when started. It will always return ignore to the supervisor. This server should be started after the database pool but before any database queries will be done.

Update tasks to be triggered by the z_install_update.erl change routines.

JSON support routines.

Define records for JSON encoding

Access control callbacks for the keyserver.

Language code handling functions.

Mandatory background read on language tags: [1].

Support for the {% lib filename ... %} tag in the templates. Generates the <link /> or %lt;script /%gt; tag for css or js files. Also adds the greatest modification date so that updates are loaded by the browser.

This is the main module that exposes custom formatting to the OTP logger library (part of the kernel application since OTP-21).

Convert markdown to/from html.

Media archiving utilities. Manages the files/archive directory of sites.

Delete medium files that were attached to deleted resources. Files are deleted after 5 weeks, which is the maximum retention period of backups and the default retention period of the filestore. This allows for a recover of deleted media items.

Images as data: urls.

Check if a GIF image is animated.

Identify files, fetch metadata about an image

Import media from internet locations. The URL is inspected and the best possible import method is used to make resource, with optionally a medium record attached.

Make still previews of media, using image manipulation functions. Resize, crop, grey, etc. This uses the command line imagemagick tools for all image manipulation.

Calculate the ImageMagick distortion parameters for a 3D rotation.

Check if an identified file is acceptable as upload.

Generate media urls and html for viewing media, based on the filename, size and optional filters. Does not generate media previews itself, this is done when fetching the image.

Manage, compile and find mediaclass definitions per context/site.

Simple memo functions. Stores much used values in the process dictionary. Especially useful for ACL lookups or often used functions. This is enabled for all HTTP and MQTT requests.

Call models, direct or via MQTT

Dummy gen_server for modules without any gen_server code. We use this dummy gen_server so that we still can use a simple otp supervisor to oversee the running modules.

Implements the module extension mechanisms for scomps, templates, actions etc. Scans all active modules for scomps (etc) and maintains lookup lists for when the system tries to find a scomp (etc).

Module manager, starts/restarts a site's modules.

Supervisor for a site's modules

Interface to MQTT pubsub functionality

Zotonic specific callbacks for MQTT connections

Tickets for MQTT out of band publish via HTTP

Encode a list of fields and/or files as multipart/form-data

Parse multipart/form-data request bodies. Uses a callback function to receive the next parts, can call a progress function to report back the progress on receiving the data.

Nonce support. Create nonces, and track nonce usage. Used nonce values are tracked for 15 minutes. Nonce values themselves are also typically valid for 15 minutes, unless another period is requested.

Simple implementation of an observer/notifier. Relays events to observers of that event. Also implements map and fold operations over the observers.

Ensure a mixed rendering becomes a valid iolist.

Simplified parsing of lists containing strings, integers, names or sub-lists.

Defines all paths for files and directories of a site.

Pivoting server for the rsc table. Takes care of full text indices. Polls the pivot queue for any changed resources.

Run a resource pivot job.

Run a pivot task queue job.

Process registry interface for a site and proc_lib routines to spawn new processes whilst keeping the logger metadata.

Query string processing, property lists and property maps for Zotonic resources.

Encode data to quoted printable strings.

Extract properties from a compact RDF document encoded by zotonic_rdf.

Render routines using wires and actions. Based on Nitrogen, which is copyright (c) 2008-2009 Rusty Klophaus

Track onetime anti replay tokens, prevent re-use within a period after being invalidated.

Interface to z_html sanitizers, sets options and adds embed sanitization.

Module for rendering and caching scomps. Scomps can be caching and non caching, depending on the passed arguments and the results of the scomp's varies/2 function.

Search the database, interfaces to specific search routines.

Map query args to query maps and vice versa. Special backwards compatible handling for repeating terms with the same name.

Combine search terms into a sql search query.

The supervisor for websocket requests and other transient processes.

Supervisor for services for a site. These can be restarted without affecting other parts.

This module is started after the complete site_sup has been booted. This is the moment for system wide initializations.

Supervisor for a zotonic site. There are two modi for a site, depending on the site's environment. If a site has environment 'backup' then it is only running the modules backup, base and filestore. The site will be fetching backups from the filestore and importing the SQL dump after it is fetched. In all other environments the site is running with all enabled modules.

Load and manage site configuration files.

Server for matching the request path to correct site and dispatch rule.

Server managing all sites running inside Zotonic. Starts the sites according to the config files in the sites subdirectories. Handles scanning of all site directories for config files.

Supervisor for sites dispatcher and manager

Supervisor for sites supervisors

Run site-specific tests in an isolated database schema

SSL support functions, create self-signed certificates

SSL support functions, ensure the DH file.

Module for handling request statistics.

Generate a HTML element with attributes, correctly escape all attributes.

Periodically cleanup leftover tempfiles in the tempdir

Template handling, compiles and renders django compatible templates using the template_compiler.

Runtime for the compiled templates with Zotonic specific interfaces.

Simple topological sort of tuples {item, [depends], [provides]}

Translate english sentences into other languages, following the GNU gettext principle.

Simple server to manage the translations, owns the ets table containing all translations. When new translations are read then the previous table is kept and the one before the previous is deleted.

Check if a user agent is a crawler

Misc utility functions for zotonic Parts are from wf_utils.erl which is Copyright (c) 2008-2009 Rusty Klophaus

Handle parameter validation of a request. Checks for the presence of z_v elements containing validation information.

Parse a XLSX spreadsheet file. As unpacking unchecked zip files can consume lots of memory, it is desirable to run this in a separate process and limit the amount of memory that can be used with: erlang:process_flag(max_heap_size, ...).

Utility functions for xml processing.

Zotonic core - main routines to 'reason' about the current Zotonic installation.

Supervisor for the zotonic application, started by zotonic_launcher.

Model behaviour

Scomp behaviour definition. A scomp is a screen component that can optionally be cached.