Removed some unused Wt stuff to make the docker image lighter

This commit is contained in:
emeric
2022-05-25 20:10:28 +02:00
parent 4c55913fac
commit d13cb3e0ad
9 changed files with 77 additions and 154 deletions
-1
View File
@@ -2,7 +2,6 @@
add_executable(lms
main.cpp
ui/Auth.cpp
ui/Bootstrap5Theme.cpp
ui/LmsApplication.cpp
ui/LmsApplicationManager.cpp
ui/LmsTheme.cpp
-77
View File
@@ -1,77 +0,0 @@
/*
* Copyright (C) 2020 Emweb bv, Herent, Belgium.
*
* See the LICENSE file for terms of use.
*/
#include "Bootstrap5Theme.h"
#include <Wt/WApplication.h>
#include <Wt/WLinkedCssStyleSheet.h>
#include <Wt/WText.h>
namespace UserInterface
{
void
Bootstrap5Theme::init(Wt::WApplication* app) const
{
app->require(resourcesUrl() + "js/bootstrap.bundle.min.js");
Wt::WString v = app->metaHeader(Wt::MetaHeaderType::Meta, "viewport");
if (v.empty())
app->addMetaHeader("viewport", "width=device-width, initial-scale=1");
}
std::string
Bootstrap5Theme::name() const
{
return "bootstrap5";
}
std::string
Bootstrap5Theme::resourcesUrl() const
{
return Wt::WApplication::relativeResourcesUrl() + "themes/bootstrap/5/";
}
std::vector<Wt::WLinkedCssStyleSheet>
Bootstrap5Theme::styleSheets() const
{
std::vector<Wt::WLinkedCssStyleSheet> result;
const std::string themeDir {resourcesUrl()};
result.emplace_back(Wt::WLink {themeDir + "css/bootstrap.min.css"});
result.emplace_back(Wt::WLink {themeDir + "wt.css"});
return result;
}
std::string
Bootstrap5Theme::utilityCssClass(int utilityCssClassRole) const
{
switch (utilityCssClassRole) {
case Wt::ToolTipInner:
return "tooltip-inner";
case Wt::ToolTipOuter:
return "tooltip fade top in";
default:
return "";
}
}
void Bootstrap5Theme::applyValidationStyle(Wt::WWidget* widget, const Wt::WValidator::Result& validation, Wt::WFlags<Wt::ValidationStyleFlag> styles) const
{
{
const bool validStyle {(validation.state() == Wt::ValidationState::Valid) && styles.test(Wt::ValidationStyleFlag::ValidStyle)};
widget->toggleStyleClass("is-valid", validStyle);
}
{
const bool invalidStyle {(validation.state() != Wt::ValidationState::Valid) && styles.test(Wt::ValidationStyleFlag::InvalidStyle)};
widget->toggleStyleClass("is-invalid", invalidStyle);
}
}
} // namespace UserInterface
-45
View File
@@ -1,45 +0,0 @@
/*
* Copyright (C) 2022 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <Wt/WTheme.h>
namespace UserInterface
{
class Bootstrap5Theme : public Wt::WTheme
{
private:
void init(Wt::WApplication *app) const override;
std::string name() const override;
std::string resourcesUrl() const override;
std::vector<Wt::WLinkedCssStyleSheet> styleSheets() const override;
void apply(Wt::WWidget*, Wt::WWidget*, int) const override {};
void apply(Wt::WWidget*, Wt::DomElement&, int) const override {};
std::string disabledClass() const override { return "disabled"; }
std::string activeClass() const override { return "active"; };
std::string utilityCssClass(int utilityCssClassRole) const override;
bool canStyleAnchorAsButton() const override { return true; };
void applyValidationStyle(Wt::WWidget* widget,
const Wt::WValidator::Result& validation,
Wt::WFlags<Wt::ValidationStyleFlag> flags) const override;
bool canBorderBoxElement(const Wt::DomElement&) const override { return true; }
};
}
+43 -19
View File
@@ -1,38 +1,62 @@
/*
* Copyright (C) 2020 Emeric Poupon
* Copyright (C) 2020 Emweb bv, Herent, Belgium.
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
* See the LICENSE file for terms of use.
*/
#include "LmsTheme.hpp"
#include "utils/Logger.hpp"
#include "LmsApplication.hpp"
#include <Wt/WApplication.h>
#include <Wt/WLinkedCssStyleSheet.h>
namespace UserInterface
{
void
LmsTheme::init(Wt::WApplication* app) const
{
app->require("js/bootstrap.bundle.min.js");
Wt::WString v = app->metaHeader(Wt::MetaHeaderType::Meta, "viewport");
if (v.empty())
app->addMetaHeader("viewport", "width=device-width, initial-scale=1, user-scalable=no");
}
std::string
LmsTheme::name() const
{
return "bootstrap5";
}
std::string
LmsTheme::resourcesUrl() const
{
return "";
}
std::vector<Wt::WLinkedCssStyleSheet>
LmsTheme::styleSheets() const
{
static const std::vector<Wt::WLinkedCssStyleSheet> files
{
{"css/bootstrap.solar.min.css"},
{"css/bootstrap.solar.min.css"}, // TODO parametrize this
{"css/lms.css"},
};
return files;
}
}
void LmsTheme::applyValidationStyle(Wt::WWidget* widget, const Wt::WValidator::Result& validation, Wt::WFlags<Wt::ValidationStyleFlag> styles) const
{
{
const bool validStyle {(validation.state() == Wt::ValidationState::Valid) && styles.test(Wt::ValidationStyleFlag::ValidStyle)};
widget->toggleStyleClass("is-valid", validStyle);
}
{
const bool invalidStyle {(validation.state() != Wt::ValidationState::Valid) && styles.test(Wt::ValidationStyleFlag::InvalidStyle)};
widget->toggleStyleClass("is-invalid", invalidStyle);
}
}
} // namespace UserInterface
+17 -7
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Emeric Poupon
* Copyright (C) 2022 Emeric Poupon
*
* This file is part of LMS.
*
@@ -19,17 +19,27 @@
#pragma once
#include <vector>
#include <Wt/WLinkedCssStyleSheet.h>
#include "Bootstrap5Theme.h"
#include <Wt/WTheme.h>
namespace UserInterface
{
class LmsTheme : public Bootstrap5Theme
class LmsTheme : public Wt::WTheme
{
private:
void init(Wt::WApplication *app) const override;
std::string name() const override;
std::string resourcesUrl() const override;
std::vector<Wt::WLinkedCssStyleSheet> styleSheets() const override;
static std::vector<Wt::WLink> getStyleSheets();
void apply(Wt::WWidget*, Wt::WWidget*, int) const override {};
void apply(Wt::WWidget*, Wt::DomElement&, int) const override {};
std::string disabledClass() const override { return "disabled"; }
std::string activeClass() const override { return "active"; };
std::string utilityCssClass(int) const override { return ""; };
bool canStyleAnchorAsButton() const override { return true; };
void applyValidationStyle(Wt::WWidget* widget,
const Wt::WValidator::Result& validation,
Wt::WFlags<Wt::ValidationStyleFlag> flags) const override;
bool canBorderBoxElement(const Wt::DomElement&) const override { return true; }
};
}