Single definition of Bloom website domain

This commit is contained in:
Nav
2021-11-02 23:26:11 +00:00
parent 15555b37c2
commit 1ef78dafb1
10 changed files with 47 additions and 15 deletions

View File

@@ -44,6 +44,12 @@ if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
# See Paths::compiledResourcesPath() for more. # See Paths::compiledResourcesPath() for more.
add_compile_definitions(BLOOM_COMPILED_RESOURCES_PATH_OVERRIDE="${CMAKE_CURRENT_SOURCE_DIR}") add_compile_definitions(BLOOM_COMPILED_RESOURCES_PATH_OVERRIDE="${CMAKE_CURRENT_SOURCE_DIR}")
# BLOOM_HOME_DOMAIN_NAME_OVERRIDE can be used to override the domain name used in URLs to the Bloom website.
# I (Nav) use this in debug builds, so I can test local changes that involve the Bloom website as well as Bloom
# itself. Other users can comment out this override if they don't have a copy of the Bloom website running on their
# local machine. See Paths::homeDomainName() for more.
add_compile_definitions(BLOOM_HOME_DOMAIN_NAME_OVERRIDE="http://bloom.local")
# CMAKE_SKIP_BUILD_RPATH needs to be set to true to use Gammaray during development. # CMAKE_SKIP_BUILD_RPATH needs to be set to true to use Gammaray during development.
# This is because the distributed Qt binaries may not be compatible with the local installation of Gammaray # This is because the distributed Qt binaries may not be compatible with the local installation of Gammaray
set(CMAKE_BUILD_RPATH /opt/Qt/6.1.2/gcc_64/lib/) set(CMAKE_BUILD_RPATH /opt/Qt/6.1.2/gcc_64/lib/)

View File

@@ -204,7 +204,9 @@ int Application::presentHelpText() {
if (!helpFile.open(QIODevice::ReadOnly)) { if (!helpFile.open(QIODevice::ReadOnly)) {
// This should never happen - if it does, something has gone very wrong // This should never happen - if it does, something has gone very wrong
throw Exception("Failed to open help file - please report this issue at https://bloom.oscillate.io/report-issue"); throw Exception(
"Failed to open help file - please report this issue at " + Paths::homeDomainName() + "/report-issue"
);
} }
std::cout << "Bloom v" << Application::VERSION.toString() << "\n"; std::cout << "Bloom v" << Application::VERSION.toString() << "\n";
@@ -221,7 +223,7 @@ int Application::presentVersionText() {
std::cout << "DEBUG BUILD - Compilation timestamp: " << __DATE__ << " " << __TIME__ << "\n"; std::cout << "DEBUG BUILD - Compilation timestamp: " << __DATE__ << " " << __TIME__ << "\n";
#endif #endif
std::cout << "https://bloom.oscillate.io/\n"; std::cout << Paths::homeDomainName() + "/\n";
std::cout << "Nav Mohammed\n"; std::cout << "Nav Mohammed\n";
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@@ -246,7 +248,10 @@ int Application::initProject() {
); );
if (!templateConfigFile.open(QIODevice::ReadOnly)) { if (!templateConfigFile.open(QIODevice::ReadOnly)) {
throw Exception("Failed to open template configuration file - please report this issue at https://bloom.oscillate.io/report-issue"); throw Exception(
"Failed to open template configuration file - please report this issue at "
+ Paths::homeDomainName() + "/report-issue"
);
} }
if (!configFile.open(QIODevice::ReadWrite)) { if (!configFile.open(QIODevice::ReadWrite)) {

View File

@@ -8,6 +8,7 @@
#include "src/TargetController/Exceptions/DeviceInitializationFailure.hpp" #include "src/TargetController/Exceptions/DeviceInitializationFailure.hpp"
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp"
#include "src/Logger/Logger.hpp" #include "src/Logger/Logger.hpp"
#include "src/Helpers/Paths.hpp"
// Command frames // Command frames
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp"
@@ -72,13 +73,13 @@ void EdbgAvr8Interface::configure(const TargetConfig& targetConfig) {
if (this->physicalInterface == PhysicalInterface::JTAG) { if (this->physicalInterface == PhysicalInterface::JTAG) {
throw InvalidConfig("The JTAG physical interface cannot be used with an ambiguous target name" throw InvalidConfig("The JTAG physical interface cannot be used with an ambiguous target name"
" - please specify the exact name of the target in your configuration file. " " - please specify the exact name of the target in your configuration file. "
"See https://bloom.oscillate.io/docs/supported-targets" "See " + Paths::homeDomainName() + "/docs/supported-targets"
); );
} else if (this->physicalInterface == PhysicalInterface::UPDI) { } else if (this->physicalInterface == PhysicalInterface::UPDI) {
throw InvalidConfig("The UPDI physical interface cannot be used with an ambiguous target name" throw InvalidConfig("The UPDI physical interface cannot be used with an ambiguous target name"
" - please specify the exact name of the target in your configuration file. " " - please specify the exact name of the target in your configuration file. "
"See https://bloom.oscillate.io/docs/supported-targets" "See " + Paths::homeDomainName() + "/docs/supported-targets"
); );
} }
} }

View File

@@ -29,6 +29,7 @@ namespace Bloom
* If the debug configuration is enabled, this function will return the absolute path to Bloom's source code, * If the debug configuration is enabled, this function will return the absolute path to Bloom's source code,
* meaning we won't use compiled resources for debug builds. This is useful for debugging and tweaking QT UI * meaning we won't use compiled resources for debug builds. This is useful for debugging and tweaking QT UI
* files such as QT stylesheets and UI templates. * files such as QT stylesheets and UI templates.
*
* @return * @return
*/ */
static inline std::string compiledResourcesPath() { static inline std::string compiledResourcesPath() {
@@ -36,6 +37,22 @@ namespace Bloom
return std::string(BLOOM_COMPILED_RESOURCES_PATH_OVERRIDE); return std::string(BLOOM_COMPILED_RESOURCES_PATH_OVERRIDE);
#else #else
return std::string(":/compiled"); return std::string(":/compiled");
#endif
}
/**
* Returns the domain name for the Bloom website.
*
* The domain name can be overridden via the BLOOM_HOME_DOMAIN_NAME_OVERRIDE compile definition.
* See CMakeLists.txt
*
* @return
*/
static inline std::string homeDomainName() {
#ifdef BLOOM_HOME_DOMAIN_NAME_OVERRIDE
return std::string(BLOOM_HOME_DOMAIN_NAME_OVERRIDE);
#else
return std::string("https://bloom.oscillate.io");
#endif #endif
} }
}; };

View File

@@ -175,7 +175,7 @@ void Insight::checkBloomVersion() {
if (latestVersionNumber > currentVersionNumber) { if (latestVersionNumber > currentVersionNumber) {
Logger::warning( Logger::warning(
"Bloom v" + latestVersionNumber.toString() "Bloom v" + latestVersionNumber.toString()
+ " is available to download - upgrade via https://bloom.oscillate.io" + " is available to download - upgrade via " + Paths::homeDomainName()
); );
} }
} }

View File

@@ -7,11 +7,13 @@
#include <QUrlQuery> #include <QUrlQuery>
#include <QJsonDocument> #include <QJsonDocument>
#include "src/Helpers/Paths.hpp"
using namespace Bloom; using namespace Bloom;
void QueryLatestVersionNumber::run(TargetControllerConsole& targetControllerConsole) { void QueryLatestVersionNumber::run(TargetControllerConsole& targetControllerConsole) {
auto* networkAccessManager = new QNetworkAccessManager(this); auto* networkAccessManager = new QNetworkAccessManager(this);
auto queryVersionEndpointUrl = QUrl("http://bloom.local/latest-version"); auto queryVersionEndpointUrl = QUrl(QString::fromStdString(Paths::homeDomainName() + "/latest-version"));
queryVersionEndpointUrl.setQuery(QUrlQuery({ queryVersionEndpointUrl.setQuery(QUrlQuery({
{"currentVersionNumber", QString::fromStdString(this->currentVersionNumber.toString())} {"currentVersionNumber", QString::fromStdString(this->currentVersionNumber.toString())}
})); }));

View File

@@ -184,7 +184,7 @@ void InsightWindow::onTargetProgramCounterUpdate(quint32 programCounter) {
} }
void InsightWindow::openReportIssuesUrl() { void InsightWindow::openReportIssuesUrl() {
auto url = QUrl("https://bloom.oscillate.io/report-issue"); auto url = QUrl(QString::fromStdString(Paths::homeDomainName() + "/report-issue"));
/* /*
* The https://bloom.oscillate.io/report-issue URL just redirects to the Bloom GitHub issue page. * The https://bloom.oscillate.io/report-issue URL just redirects to the Bloom GitHub issue page.
* *
@@ -209,7 +209,7 @@ void InsightWindow::openReportIssuesUrl() {
} }
void InsightWindow::openGettingStartedUrl() { void InsightWindow::openGettingStartedUrl() {
QDesktopServices::openUrl(QUrl("https://bloom.oscillate.io/docs/getting-started")); QDesktopServices::openUrl(QUrl(QString::fromStdString(Paths::homeDomainName() + "/docs/getting-started")));
} }
void InsightWindow::openAboutWindow() { void InsightWindow::openAboutWindow() {

View File

@@ -368,5 +368,5 @@ void TargetRegisterInspectorWindow::applyChanges() {
} }
void TargetRegisterInspectorWindow::openHelpPage() { void TargetRegisterInspectorWindow::openHelpPage() {
QDesktopServices::openUrl(QUrl("https://bloom.oscillate.io/docs/register-inspection")); QDesktopServices::openUrl(QUrl(QString::fromStdString(Paths::homeDomainName() + "/docs/register-inspection")));
} }

View File

@@ -108,8 +108,8 @@ void TargetController::checkUdevRules() {
Logger::error("Bloom udev rules missing - cannot install udev rules without root privileges.\n" Logger::error("Bloom udev rules missing - cannot install udev rules without root privileges.\n"
"Running Bloom once with root privileges will allow it to automatically install the udev rules. " "Running Bloom once with root privileges will allow it to automatically install the udev rules. "
"Alternatively, instructions on manually installing the udev rules can be found " "Alternatively, instructions on manually installing the udev rules can be found "
"here: https://bloom.oscillate.io/docs/getting-started\nBloom may fail to connect to some debug tools " "here: " + Paths::homeDomainName() + "/docs/getting-started\nBloom may fail to connect to some "
"until this is resolved."); "debug tools until this is resolved.");
return; return;
} }

View File

@@ -5,6 +5,7 @@
#include "Exceptions/TargetDescriptionParsingFailureException.hpp" #include "Exceptions/TargetDescriptionParsingFailureException.hpp"
#include "src/Logger/Logger.hpp" #include "src/Logger/Logger.hpp"
#include "src/Helpers/Paths.hpp"
using namespace Bloom::Targets::TargetDescription; using namespace Bloom::Targets::TargetDescription;
using namespace Bloom::Exceptions; using namespace Bloom::Exceptions;
@@ -24,7 +25,7 @@ void TargetDescriptionFile::init(const QString& xmlFilePath) {
auto xml = QDomDocument(); auto xml = QDomDocument();
if (!xml.setContent(file.readAll())) { if (!xml.setContent(file.readAll())) {
throw Exception("Failed to parse target description file - please report this error " throw Exception("Failed to parse target description file - please report this error "
"to Bloom developers via https://bloom.oscillate.io/report-issue"); "to Bloom developers via " + Paths::homeDomainName() + "/report-issue");
} }
this->init(xml); this->init(xml);