Mercurial > sci
view scid/theme.h @ 37:62aefd02ac59
make: remove config.mk
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 07 Aug 2022 08:41:06 +0200 |
parents | 1d0ddf9e6efd |
children | 752bb1cd2dd8 |
line wrap: on
line source
/* * theme.h -- theme management * * Copyright (c) 2021-2022 David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef SCID_THEME_H #define SCID_THEME_H /** * \file theme.h * \brief Theme management * * Themes are written in Javascript and usually with a combination of * [mustache][] files as well. The Javascript code is executed before rendering * the page with a JSON document containing the data to generate. * * This has been designed to address the issue that many web frameworks require * different kind of HTML entities to generate the view and as such, the scid * application can not generate those HTML tags. * * This module uses a global Javascript context to perform rendering, you must * call theme_open before doing anything else. Once done, use theme_finish to * cleanup resources. * * This module logs message with tag `theme`. * * [mustache]: https://mustache.github.io/ */ #include <jansson.h> #include "pageutil.h" /** * Open the theme specified by directory path. * * \pre directory != NULL * \param directory path to the theme directory (absolute path is recommended). */ void theme_open(const char *directory); /** * Return the path to the filename relative to the theme directory. * * \pre filename != NULL * \param filename the filename to append * \return the full path * \note This function return a thread-local static variable. */ const char * theme_path(const char *filename); /** * Render the index page. * * The document requires the following properties: * * ``` * { * "projects: [ * { * "name": "project name", * "desc": "project short description", * "url": "project URL or homepage", * "jobs": [ * { * "job": job-id, * "tag": "job tag / revision", * "status": "failed / success" // failed if at least one has failed * } * ] * "n-failed": number of failed jobs * "n-succes": number of successful jobs * } * ] * } * ``` * * \pre doc != NULL * \param doc the page document * \return a newly allocated rendered string * \note You must free the return value */ char * theme_page_index(const json_t *doc); /** * Render the status page (for error code). * * The document requires the following properties: * * ``` * { * "status": number // Exemple: 400, 401 * } * ``` * * \param status the status code * \return a newly allocated rendered string * \note You must free the return value */ char * theme_page_status(enum khttp status); /** * Cleanup theme resources. */ void theme_finish(void); #endif /* !SCID_THEME_H */