Webdar 1.0.0
Web user interface to libdar
html_mask_form_path.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef HTML_MASK_FORM_PATH_HPP
25#define HTML_MASK_FORM_PATH_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <dar/libdar.hpp>
36
37 // webdar headers
38#include "body_builder.hpp"
39#include "actor.hpp"
40#include "events.hpp"
41#include "html_form_dynamic_table.hpp"
42#include "jsoner.hpp"
43#include "html_mask.hpp"
44#include "bibliotheque_subconfig.hpp"
45#include "html_form.hpp"
46#include "html_form_mask_bool.hpp"
47
48
50
53
55 public actor,
56 public events,
58 public jsoner,
59 public html_mask,
61{
62public:
63 static const std::string changed;
64
66
69 html_mask_form_path(bool allow_absolute_paths);
71 html_mask_form_path(html_mask_form_path && ref) noexcept = delete;
72 html_mask_form_path & operator = (const html_mask_form_path & ref) = delete;
73 html_mask_form_path & operator = (html_mask_form_path && ref) noexcept = delete;
74 ~html_mask_form_path() = default;
75
77 void set_child(const std::shared_ptr<bibliotheque> & ptr,
79
80
82
85 void set_fs_root(const std::string & prefix);
86
88 virtual std::unique_ptr<libdar::mask> get_mask() const override { return root.get_mask(); };
89
91 virtual bool is_relative() const override { return root.is_relative(); };
92
93
95 virtual std::unique_ptr<body_builder> provide_object_of_type(unsigned int num,
96 const std::string & context,
97 std::string & changed_event) const override;
98
100 virtual void load_json(const json & source) override;
101
103 virtual json save_json() const override;
104
106 virtual void clear_json() override;
107
109 virtual bibliotheque::using_set get_using_set() const override;
110
112 virtual void on_event(const std::string & event_name) override;
113
115 virtual void bind_to_anchor(const std::string & val) override { form.bind_to_anchor(val); };
116
117protected:
118
120 virtual std::string inherited_get_body_part(const chemin & path,
121 const request & req) override;
122
124 virtual void css_classes_have_changed() override;
125
126private:
127 bool allow_abs_paths;
128 std::deque<std::string> labels;
130 std::shared_ptr<bibliotheque> biblio;
131 std::shared_ptr<libdar::path> fs_root;
132 // the use of a shared_ptr is done here because this
133 // information will be shared with a possibly wide
134 // range of objects we will provide (as object
135 // provider) stored in a possibly rich tree-like structure
136 // (html_form_mask_bool) and this info may be needed
137 // to be updated from time to time. Other objects
138 // get notified of changes by mean of events triggered
139 // by this html_mask_form_path object
140
141 html_form form;
143
144 void init();
145 void init_bool_obj(html_form_mask_bool & obj) const;
146 void check_ptr() const;
147
148 static constexpr const unsigned int format_version = 1;
149 static constexpr const char* myclass_id = "html_mask_form_path";
150
151 static constexpr const char* jlabel_bool_config = "bool-config";
152
153};
154
155#endif
class of object that are pointed/triggered to by others
Definition: actor.hpp:55
class bibliotheque_subconfig is an interface (pure virtual class)
Definition: bibliotheque_subconfig.hpp:50
std::set< coordinates > using_set
list of configs a given config depends on
Definition: bibliotheque.hpp:117
category
change event is replaced by a static method with category in argument
Definition: bibliotheque.hpp:63
class body_builder is the root class of object generating HTML body
Definition: body_builder.hpp:99
class chemin definition
Definition: chemin.hpp:51
class events
Definition: events.hpp:52
class html_form_dynamic_table_object_provider
Definition: html_form_dynamic_table.hpp:60
class html_form_mask_bool provide mean to combines with OR and AND different html_masks
Definition: html_form_mask_bool.hpp:88
virtual std::unique_ptr< libdar::mask > get_mask() const override
inherited from html_mask
Definition: html_form_mask_bool.cpp:83
virtual bool is_relative() const override
inherited from html_mask
Definition: html_form_mask_bool.cpp:144
class html_form implements HTML form feature
Definition: html_form.hpp:51
virtual void bind_to_anchor(const std::string &value) override
inherited from body_builder
Definition: html_form.hpp:83
class html_mask_form_path let user define mask on paths
Definition: html_mask_form_path.hpp:61
virtual std::string inherited_get_body_part(const chemin &path, const request &req) override
inherited from body_builder
Definition: html_mask_form_path.cpp:255
virtual bool is_relative() const override
inherited from html_mask
Definition: html_mask_form_path.hpp:91
virtual void load_json(const json &source) override
inherited from jsoner
Definition: html_mask_form_path.cpp:180
virtual void on_event(const std::string &event_name) override
inherited from actor
Definition: html_mask_form_path.cpp:245
virtual void css_classes_have_changed() override
inherited from body_builder
Definition: html_mask_form_path.cpp:261
virtual bibliotheque::using_set get_using_set() const override
inherited from bibliotheque_subconfig
Definition: html_mask_form_path.cpp:240
virtual json save_json() const override
inherited from jsoner
Definition: html_mask_form_path.cpp:213
void set_fs_root(const std::string &prefix)
set filesystem root value
Definition: html_mask_form_path.cpp:90
virtual void bind_to_anchor(const std::string &val) override
inherited from body_builder
Definition: html_mask_form_path.hpp:115
virtual std::unique_ptr< body_builder > provide_object_of_type(unsigned int num, const std::string &context, std::string &changed_event) const override
inherited from html_form_dynamic_table
Definition: html_mask_form_path.cpp:111
virtual std::unique_ptr< libdar::mask > get_mask() const override
inherited from html_mask
Definition: html_mask_form_path.hpp:88
virtual void clear_json() override
inherited from jsoner
Definition: html_mask_form_path.cpp:230
void set_child(const std::shared_ptr< bibliotheque > &ptr, bibliotheque::category cat)
should be invoked ASAP after object construction
Definition: html_mask_form_path.cpp:83
html_mask_form_path(bool allow_absolute_paths)
constructor
Definition: html_mask_form_path.cpp:46
class html_mask defines the interface of all masks
Definition: html_mask.hpp:44
class jsoner
Definition: jsoner.hpp:73
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
defines the event class
defines jsoner class and class exception_json