Skip to content

Commit

Permalink
Code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed Nov 30, 2023
1 parent 118bf61 commit 2e0e592
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions collaboration/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
#include <database/config/bible.h>
#include <dialog/list.h>
#include <menu/logic.h>
using namespace std;


string collaboration_index_url ()
std::string collaboration_index_url ()
{
return "collaboration/index";
}
Expand All @@ -47,11 +46,11 @@ bool collaboration_index_acl (void * webserver_request)
}


string collaboration_index (void * webserver_request)
std::string collaboration_index (void * webserver_request)
{
Webserver_Request * request = static_cast<Webserver_Request *>(webserver_request);

string page;
std::string page {};
Assets_Header header = Assets_Header (translate("Repository"), request);
header.add_bread_crumb (menu_logic_settings_menu (), menu_logic_settings_text ());
page = header.run ();
Expand All @@ -61,14 +60,14 @@ string collaboration_index (void * webserver_request)
#ifdef HAVE_CLOUD


string object = request->query ["object"];
std::string object = request->query ["object"];
if (request->query.count ("select")) {
string select = request->query["select"];
if (select == "") {
const std::string& select = request->query["select"];
if (select.empty()) {
Dialog_List dialog_list = Dialog_List ("index", translate("Which Bible are you going to use?"), "", "");
dialog_list.add_query ("object", object);
vector <string> bibles = request->database_bibles()->get_bibles();
for (auto & value : bibles) {
const std::vector <std::string>& bibles = request->database_bibles()->get_bibles();
for (const auto& value : bibles) {
dialog_list.add_row (value, "select", value);
}
page += dialog_list.run ();
Expand All @@ -81,14 +80,14 @@ string collaboration_index (void * webserver_request)
if (!object.empty ()) view.enable_zone ("objectactive");


string repositoryfolder = filter_git_directory (object);
const std::string& repositoryfolder = filter_git_directory (object);


if (request->query.count ("disable")) {
Database_Config_Bible::setRemoteRepositoryUrl (object, "");
filter_url_rmdir (repositoryfolder);
}
string url = Database_Config_Bible::getRemoteRepositoryUrl (object);
const std::string& url = Database_Config_Bible::getRemoteRepositoryUrl (object);
view.set_variable ("url", url);
if (url.empty ()) {
view.enable_zone ("urlinactive");
Expand All @@ -104,7 +103,7 @@ string collaboration_index (void * webserver_request)
// And the standard error output is needed in case of failures.
// So the following is used instead.
if (!object.empty ()) {
string statusoutput, statuserror;
std::string statusoutput, statuserror;
filter_shell_run (repositoryfolder, "git", {"status"}, &statusoutput, &statuserror);
view.set_variable ("status", statusoutput + " " + statuserror);
}
Expand Down

0 comments on commit 2e0e592

Please sign in to comment.