Skip to content

Commit

Permalink
Move from class with all static members to a namespace with functions
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed May 25, 2024
1 parent 3d04fd1 commit 024613a
Show file tree
Hide file tree
Showing 89 changed files with 681 additions and 685 deletions.
4 changes: 2 additions & 2 deletions assets/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void Assets_Header::set_navigator ()
void Assets_Header::set_stylesheet ()
{
const std::string bible = m_webserver_request.database_config_user()->getBible ();
const std::string stylesheet = Database_Config_Bible::getEditorStylesheet (bible);
const std::string stylesheet = database::config::bible::getEditorStylesheet (bible);
m_included_stylesheet = std::move(stylesheet);
}

Expand All @@ -85,7 +85,7 @@ void Assets_Header::set_stylesheet ()
void Assets_Header::set_editor_stylesheet ()
{
const std::string bible = m_webserver_request.database_config_user()->getBible ();
const std::string stylesheet = Database_Config_Bible::getEditorStylesheet (bible);
const std::string stylesheet = database::config::bible::getEditorStylesheet (bible);
m_included_editor_stylesheet = std::move(stylesheet);
}

Expand Down
18 changes: 9 additions & 9 deletions bb/css.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ std::string bible_css (Webserver_Request& webserver_request)
font = filter::strings::trim (font);
#ifdef HAVE_CLIENT
// Bibledit client storage.
Database_Config_Bible::setTextFontClient (bible, font);
database::config::bible::setTextFontClient (bible, font);
#else
// Bibledit Cloud storage.
Database_Config_Bible::setTextFont (bible, font);
database::config::bible::setTextFont (bible, font);
#endif

const std::string s_direction = webserver_request.post ["direction"];
Expand All @@ -80,17 +80,17 @@ std::string bible_css (Webserver_Request& webserver_request)
const std::string s_mode = webserver_request.post ["mode"];
const int i_mode = Filter_Css::writingModeValue (s_mode);

Database_Config_Bible::setTextDirection (bible, i_mode * 10 + i_direction);
database::config::bible::setTextDirection (bible, i_mode * 10 + i_direction);

int lineheight = filter::strings::convert_to_int (webserver_request.post["lineheight"]);
if (lineheight < 50) lineheight = 50;
if (lineheight > 300) lineheight = 300;
Database_Config_Bible::setLineHeight (bible, lineheight);
database::config::bible::setLineHeight (bible, lineheight);

float letterspacing = filter::strings::convert_to_float (webserver_request.post["letterspacing"]);
if (letterspacing < -3) letterspacing = -3;
if (letterspacing > 3) letterspacing = 3;
Database_Config_Bible::setLetterSpacing (bible, static_cast<int>(10 * letterspacing));
database::config::bible::setLetterSpacing (bible, static_cast<int>(10 * letterspacing));

page += assets_page::success ("The information was saved.");
}
Expand All @@ -102,7 +102,7 @@ std::string bible_css (Webserver_Request& webserver_request)
const std::string font = fonts::logic::get_text_font (bible);
view.set_variable ("font", font);

const int direction = Database_Config_Bible::getTextDirection (bible);
const int direction = database::config::bible::getTextDirection (bible);

view.set_variable ("direction_none", Filter_Css::directionUnspecified (direction));
view.set_variable ("direction_ltr", Filter_Css::directionLeftToRight (direction));
Expand All @@ -114,10 +114,10 @@ std::string bible_css (Webserver_Request& webserver_request)
view.set_variable ("mode_btlr", Filter_Css::writingModeBottomTopLeftRight (direction));
view.set_variable ("mode_btrl", Filter_Css::writingModeBottomTopRightLeft (direction));

const int lineheight = Database_Config_Bible::getLineHeight (bible);
const int lineheight = database::config::bible::getLineHeight (bible);
view.set_variable ("lineheight", filter::strings::convert_to_string (lineheight));

float letterspacing = static_cast<float> (Database_Config_Bible::getLetterSpacing (bible));
float letterspacing = static_cast<float> (database::config::bible::getLetterSpacing (bible));
letterspacing /= 10;
view.set_variable ("letterspacing", filter::strings::convert_to_string (letterspacing));

Expand All @@ -126,7 +126,7 @@ std::string bible_css (Webserver_Request& webserver_request)
const std::string custom_css = Filter_Css::get_css (custom_class,
fonts::logic::get_font_path (font), direction,
lineheight,
Database_Config_Bible::getLetterSpacing (bible));
database::config::bible::getLetterSpacing (bible));
view.set_variable ("custom_css", custom_css);

page += view.render ("bb", "css");
Expand Down
4 changes: 2 additions & 2 deletions bb/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void bible_logic::delete_bible (const std::string& bible)

// Delete associated settings and privileges.
DatabasePrivileges::remove_bible (bible);
Database_Config_Bible::remove (bible);
database::config::bible::remove (bible);
}


Expand Down Expand Up @@ -281,7 +281,7 @@ void bible_logic::log_change (const std::string& bible,
const std::string bookname = database::books::get_english_from_id (static_cast<book_id>(book));
const std::string passage = bible + " " + bookname + " " + filter::strings::convert_to_string (chapter);

const std::string stylesheet = Database_Config_Bible::getExportStylesheet (bible);
const std::string stylesheet = database::config::bible::getExportStylesheet (bible);

const std::vector <int> existing_verse_numbers = filter::usfm::get_verse_numbers (existing_usfm);
const std::vector <int> verse_numbers = filter::usfm::get_verse_numbers (usfm);
Expand Down
8 changes: 4 additions & 4 deletions bb/order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ std::string bible_order (Webserver_Request& webserver_request)
std::vector <std::string> v_book_order {};
for (const auto book : interspersed) v_book_order.push_back (filter::strings::convert_to_string (static_cast<int>(book)));
const std::string s_book_order = filter::strings::implode (v_book_order, " ");
Database_Config_Bible::setBookOrder (bible, s_book_order);
database::config::bible::setBookOrder (bible, s_book_order);
}


Expand Down Expand Up @@ -176,13 +176,13 @@ std::string bible_order (Webserver_Request& webserver_request)
std::vector <std::string> v_book_order {};
for (const auto book : interspersed) v_book_order.push_back (filter::strings::convert_to_string (static_cast<int>(book)));
const std::string s_book_order = filter::strings::implode (v_book_order, " ");
Database_Config_Bible::setBookOrder (bible, s_book_order);
database::config::bible::setBookOrder (bible, s_book_order);
}


// Deuterocanonicals or Apocrypha at the end of the entire Bible.
if (order == "end") {
Database_Config_Bible::setBookOrder (bible, std::string());
database::config::bible::setBookOrder (bible, std::string());
}

// Handle updates to the custom book order.
Expand All @@ -196,7 +196,7 @@ std::string bible_order (Webserver_Request& webserver_request)
s_books.push_back (filter::strings::convert_to_string (book));
filter::strings::array_move_up_down (s_books, move, !moveup.empty ());
const std::string s_order = filter::strings::implode (s_books, " ");
Database_Config_Bible::setBookOrder (bible, s_order);
database::config::bible::setBookOrder (bible, s_order);
}

const std::vector <int> books = filter_passage_get_ordered_books (bible);
Expand Down
24 changes: 12 additions & 12 deletions bb/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ std::string bible_settings (Webserver_Request& webserver_request)
page += dialog_list.run ();
return page;
} else {
if (write_access) Database_Config_Bible::setVersificationSystem (bible, versification);
if (write_access) database::config::bible::setVersificationSystem (bible, versification);
}
}
const std::string versification = Database_Config_Bible::getVersificationSystem (bible);
const std::string versification = database::config::bible::getVersificationSystem (bible);
view.set_variable ("versification", versification);


Expand Down Expand Up @@ -228,21 +228,21 @@ std::string bible_settings (Webserver_Request& webserver_request)

// Public feedback.
if (checkbox == "public") {
if (write_access) Database_Config_Bible::setPublicFeedbackEnabled (bible, checked);
if (write_access) database::config::bible::setPublicFeedbackEnabled (bible, checked);
}
view.set_variable ("public", filter::strings::get_checkbox_status (Database_Config_Bible::getPublicFeedbackEnabled (bible)));
view.set_variable ("public", filter::strings::get_checkbox_status (database::config::bible::getPublicFeedbackEnabled (bible)));



// RSS feed.
#ifdef HAVE_CLOUD
if (checkbox == "rss") {
if (write_access) {
Database_Config_Bible::setSendChangesToRSS (bible, checked);
database::config::bible::setSendChangesToRSS (bible, checked);
rss_logic_feed_on_off ();
}
}
view.set_variable ("rss", filter::strings::get_checkbox_status (Database_Config_Bible::getSendChangesToRSS (bible)));
view.set_variable ("rss", filter::strings::get_checkbox_status (database::config::bible::getSendChangesToRSS (bible)));
#endif


Expand All @@ -260,10 +260,10 @@ std::string bible_settings (Webserver_Request& webserver_request)
page += dialog_list.run ();
return page;
} else {
if (write_access) Database_Config_Bible::setEditorStylesheet (bible, stylesheet);
if (write_access) database::config::bible::setEditorStylesheet (bible, stylesheet);
}
}
std::string stylesheet = Database_Config_Bible::getEditorStylesheet (bible);
std::string stylesheet = database::config::bible::getEditorStylesheet (bible);
view.set_variable ("stylesheetediting", stylesheet);


Expand All @@ -281,26 +281,26 @@ std::string bible_settings (Webserver_Request& webserver_request)
page += dialog_list.run ();
return page;
} else {
if (write_access) Database_Config_Bible::setExportStylesheet (bible, export_stylesheet);
if (write_access) database::config::bible::setExportStylesheet (bible, export_stylesheet);
}
}
stylesheet = Database_Config_Bible::getExportStylesheet (bible);
stylesheet = database::config::bible::getExportStylesheet (bible);
view.set_variable ("stylesheetexport", stylesheet);


// Automatic daily checks on text.
#ifdef HAVE_CLOUD
if (checkbox == "checks") {
if (write_access) {
Database_Config_Bible::setDailyChecksEnabled (bible, checked);
database::config::bible::setDailyChecksEnabled (bible, checked);
if (!checked) {
// If checking is switched off, also remove any existing checking results for this Bible.
Database_Check database_check;
database_check.truncateOutput(bible);
}
}
}
view.set_variable ("checks", filter::strings::get_checkbox_status (Database_Config_Bible::getDailyChecksEnabled (bible)));
view.set_variable ("checks", filter::strings::get_checkbox_status (database::config::bible::getDailyChecksEnabled (bible)));
#endif


Expand Down
2 changes: 1 addition & 1 deletion book/create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool book_create (const std::string & bible, const book_id book, const int chapt


// Subsequent chapters.
const std::string versification = Database_Config_Bible::getVersificationSystem (bible);
const std::string versification = database::config::bible::getVersificationSystem (bible);
const std::vector <Passage> versification_data = database_versifications.getBooksChaptersVerses (versification);
for (const auto& row : versification_data) {
if (book == static_cast<book_id>(row.m_book)) {
Expand Down
4 changes: 2 additions & 2 deletions changes/modifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void changes_process_identifiers (Webserver_Request& webserver_request,
{
if (oldId != 0) {
Database_Modifications database_modifications {};
const std::string stylesheet = Database_Config_Bible::getExportStylesheet (bible);
const std::string stylesheet = database::config::bible::getExportStylesheet (bible);
Database_Modifications_Text old_chapter_text = database_modifications.getUserChapter (user, bible, book, chapter, oldId);
const std::string old_chapter_usfm = old_chapter_text.oldtext;
Database_Modifications_Text new_chapter_text = database_modifications.getUserChapter (user, bible, book, chapter, newId);
Expand Down Expand Up @@ -279,7 +279,7 @@ void changes_modifications ()
for (const auto & bible : bibles) {


const std::string stylesheet = Database_Config_Bible::getExportStylesheet (bible);
const std::string stylesheet = database::config::bible::getExportStylesheet (bible);


std::vector <std::string> changeNotificationUsers;
Expand Down
2 changes: 1 addition & 1 deletion checks/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void checks_logic_start_all ()
Database_Bibles database_bibles {};
const std::vector <std::string>& bibles = database_bibles.get_bibles ();
for (const auto& bible : bibles) {
const bool enabled = Database_Config_Bible::getDailyChecksEnabled (bible);
const bool enabled = database::config::bible::getDailyChecksEnabled (bible);
if (enabled) checks_logic_start (bible);
}
}
Expand Down
54 changes: 27 additions & 27 deletions checks/run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,38 @@ void checks_run (std::string bible)
database_check.truncateOutput (bible);


const std::string stylesheet = Database_Config_Bible::getExportStylesheet (bible);
const std::string stylesheet = database::config::bible::getExportStylesheet (bible);


bool check_double_spaces_usfm = Database_Config_Bible::getCheckDoubleSpacesUsfm (bible);
bool check_full_stop_in_headings = Database_Config_Bible::getCheckFullStopInHeadings (bible);
bool check_space_before_punctuation = Database_Config_Bible::getCheckSpaceBeforePunctuation (bible);
bool check_space_before_final_note_marker = Database_Config_Bible::getCheckSpaceBeforeFinalNoteMarker (bible);
bool check_sentence_structure = Database_Config_Bible::getCheckSentenceStructure (bible);
bool check_paragraph_structure = Database_Config_Bible::getCheckParagraphStructure (bible);
bool check_double_spaces_usfm = database::config::bible::getCheckDoubleSpacesUsfm (bible);
bool check_full_stop_in_headings = database::config::bible::getCheckFullStopInHeadings (bible);
bool check_space_before_punctuation = database::config::bible::getCheckSpaceBeforePunctuation (bible);
bool check_space_before_final_note_marker = database::config::bible::getCheckSpaceBeforeFinalNoteMarker (bible);
bool check_sentence_structure = database::config::bible::getCheckSentenceStructure (bible);
bool check_paragraph_structure = database::config::bible::getCheckParagraphStructure (bible);
Checks_Sentences checks_sentences;
checks_sentences.enter_capitals (Database_Config_Bible::getSentenceStructureCapitals (bible));
checks_sentences.enter_small_letters (Database_Config_Bible::getSentenceStructureSmallLetters (bible));
std::string end_marks = Database_Config_Bible::getSentenceStructureEndPunctuation (bible);
checks_sentences.enter_capitals (database::config::bible::getSentenceStructureCapitals (bible));
checks_sentences.enter_small_letters (database::config::bible::getSentenceStructureSmallLetters (bible));
std::string end_marks = database::config::bible::getSentenceStructureEndPunctuation (bible);
checks_sentences.enter_end_marks (end_marks);
std::string center_marks = Database_Config_Bible::getSentenceStructureMiddlePunctuation (bible);
std::string center_marks = database::config::bible::getSentenceStructureMiddlePunctuation (bible);
checks_sentences.enter_center_marks (center_marks);
std::string disregards = Database_Config_Bible::getSentenceStructureDisregards (bible);
std::string disregards = database::config::bible::getSentenceStructureDisregards (bible);
checks_sentences.enter_disregards (disregards);
checks_sentences.enter_names (Database_Config_Bible::getSentenceStructureNames (bible));
std::vector <std::string> within_sentence_paragraph_markers = filter::strings::explode (Database_Config_Bible::getSentenceStructureWithinSentenceMarkers (bible), ' ');
bool check_books_versification = Database_Config_Bible::getCheckBooksVersification (bible);
bool check_chapters_verses_versification = Database_Config_Bible::getCheckChaptesVersesVersification (bible);
bool check_well_formed_usfm = Database_Config_Bible::getCheckWellFormedUsfm (bible);
checks_sentences.enter_names (database::config::bible::getSentenceStructureNames (bible));
std::vector <std::string> within_sentence_paragraph_markers = filter::strings::explode (database::config::bible::getSentenceStructureWithinSentenceMarkers (bible), ' ');
bool check_books_versification = database::config::bible::getCheckBooksVersification (bible);
bool check_chapters_verses_versification = database::config::bible::getCheckChaptesVersesVersification (bible);
bool check_well_formed_usfm = database::config::bible::getCheckWellFormedUsfm (bible);
Checks_Usfm checks_usfm = Checks_Usfm (bible);
bool check_missing_punctuation_end_verse = Database_Config_Bible::getCheckMissingPunctuationEndVerse (bible);
bool check_patterns = Database_Config_Bible::getCheckPatterns (bible);
std::string s_checking_patterns = Database_Config_Bible::getCheckingPatterns (bible);
bool check_missing_punctuation_end_verse = database::config::bible::getCheckMissingPunctuationEndVerse (bible);
bool check_patterns = database::config::bible::getCheckPatterns (bible);
std::string s_checking_patterns = database::config::bible::getCheckingPatterns (bible);
std::vector <std::string> checking_patterns = filter::strings::explode (s_checking_patterns, '\n');
bool check_matching_pairs = Database_Config_Bible::getCheckMatchingPairs (bible);
bool check_matching_pairs = database::config::bible::getCheckMatchingPairs (bible);
std::vector <std::pair <std::string, std::string> > matching_pairs;
{
const std::string fragment = Database_Config_Bible::getMatchingPairs (bible);
const std::string fragment = database::config::bible::getMatchingPairs (bible);
std::vector <std::string> pairs = filter::strings::explode (fragment, ' ');
for (auto& pair : pairs) {
pair = filter::strings::trim (pair);
Expand All @@ -109,11 +109,11 @@ void checks_run (std::string bible)
}
}
}
bool check_space_end_verse = Database_Config_Bible::getCheckSpaceEndVerse (bible);
bool check_french_punctuation = Database_Config_Bible::getCheckFrenchPunctuation (bible);
bool check_french_citation_style = Database_Config_Bible::getCheckFrenchCitationStyle (bible);
bool transpose_fix_space_in_notes = Database_Config_Bible::getTransposeFixSpacesNotes (bible);
bool check_valid_utf8_text = Database_Config_Bible::getCheckValidUTF8Text (bible);
bool check_space_end_verse = database::config::bible::getCheckSpaceEndVerse (bible);
bool check_french_punctuation = database::config::bible::getCheckFrenchPunctuation (bible);
bool check_french_citation_style = database::config::bible::getCheckFrenchCitationStyle (bible);
bool transpose_fix_space_in_notes = database::config::bible::getTransposeFixSpacesNotes (bible);
bool check_valid_utf8_text = database::config::bible::getCheckValidUTF8Text (bible);


const std::vector <int> books = webserver_request.database_bibles()->get_books (bible);
Expand Down
Loading

0 comments on commit 024613a

Please sign in to comment.