Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
markdown/idclass: add ic_doc member
  • Loading branch information
perexg committed Mar 30, 2016
1 parent ff9dab0 commit 0128c90
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/access.c
Expand Up @@ -1433,11 +1433,26 @@ theme_get_ui_list ( void *p, const char *lang )
return strtab2htsmsg_str(tab, 1, lang);
}

static const char *access_entry_doc[] = {
N_("Setting up access control is an important initial step as "
"**the system is initially wide open**."),
N_("Tvheadend verifies access by scanning through all enabled access control "
"entries in sequence, from the top of the list to the bottom. "
"The permission flags, streaming profiles, DVR config profiles, "
"channel tags and so on are combined for all matching access entries. "
"An access entry is said to match if the username matches and the IP "
"source address of the requesting peer is within the prefix. There is "
"also anonymous access, if the user is set to asterisk. Only network "
"prefix is matched then."),
NULL
};

const idclass_t access_entry_class = {
.ic_class = "access",
.ic_caption = N_("Access"),
.ic_event = "access",
.ic_perm_def = ACCESS_ADMIN,
.ic_doc = access_entry_doc,
.ic_save = access_entry_class_save,
.ic_get_title = access_entry_class_get_title,
.ic_delete = access_entry_class_delete,
Expand Down
1 change: 1 addition & 0 deletions src/idnode.h
Expand Up @@ -67,6 +67,7 @@ struct idclass {
const char *ic_class; ///< Class name
const char *ic_caption; ///< Class description
const char *ic_order; ///< Property order (comma-separated)
const char **ic_doc; ///< NULL terminated array of strings
const property_group_t *ic_groups; ///< Groups for visual representation
const property_t *ic_properties; ///< Property list
const char *ic_event; ///< Events to fire on add/delete/title
Expand Down
24 changes: 20 additions & 4 deletions src/webui/doc_md.c
Expand Up @@ -129,28 +129,45 @@ http_markdown_class(http_connection_t *hc, const char *clazz)
htsbuf_queue_t *hq = &hc->hc_reply;
htsmsg_t *m, *l, *n, *e, *x;
htsmsg_field_t *f, *f2;
const char *s;
int nl = 0;
const char *s, **doc;
int nl = 0, first = 1;

pthread_mutex_lock(&global_lock);
ic = idclass_find(clazz);
if (ic == NULL) {
pthread_mutex_unlock(&global_lock);
return HTTP_STATUS_NOT_FOUND;
}
doc = ic->ic_doc;
m = idclass_serialize(ic, lang);
pthread_mutex_unlock(&global_lock);
s = htsmsg_get_str(m, "caption");
if (s) {
md_header(hq, "####", s);
md_header(hq, "##", s);
nl = 1;
}
for (; *doc; doc++) {
md_nl(hq, 1);
md_text(hq, NULL, NULL, tvh_gettext_lang(lang, *doc));
md_nl(hq, 1);
}
l = htsmsg_get_list(m, "props");
HTSMSG_FOREACH(f, l) {
n = htsmsg_field_get_map(f);
if (!n) continue;
s = htsmsg_get_str(n, "caption");
if (!s) continue;
if (first) {
md_nl(hq, 1);
md_nl(hq, 1);
htsbuf_append_str(hq, "####");
htsbuf_append_str(hq, tvh_gettext_lang(lang, N_("Items")));
md_nl(hq, 1);
md_nl(hq, 1);
htsbuf_append_str(hq, tvh_gettext_lang(lang, N_("The items have the following functions:")));
md_nl(hq, 1);
first = 0;
}
nl = md_nl(hq, nl);
md_style(hq, "**", s);
md_nl(hq, 1);
Expand All @@ -176,7 +193,6 @@ http_markdown_class(http_connection_t *hc, const char *clazz)
}
md_nl(hq, 1);
}
htsmsg_print(n);
}
htsmsg_destroy(m);
return 0;
Expand Down

0 comments on commit 0128c90

Please sign in to comment.