mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
Help+LibManual: Without arguments, open index page instead of crashing
This is the old behavior before the recent LibManual refactor. It also moves the definition of the index page into LibManual for better reuse.
This commit is contained in:
parent
cda5a530e6
commit
5a346c4297
4 changed files with 11 additions and 3 deletions
|
@ -213,7 +213,7 @@ ErrorOr<void> MainWidget::set_start_page(Vector<StringView, 2> query_parameters)
|
||||||
|
|
||||||
ErrorOr<void> MainWidget::initialize_fallibles(GUI::Window& window)
|
ErrorOr<void> MainWidget::initialize_fallibles(GUI::Window& window)
|
||||||
{
|
{
|
||||||
static String const help_index_path = TRY(TRY(try_make_ref_counted<Manual::PageNode>(Manual::sections[7 - 1], TRY(String::from_utf8("Help-index"sv))))->path());
|
static String const help_index_path = TRY(TRY(Manual::PageNode::help_index_page())->path());
|
||||||
m_go_home_action = GUI::CommonActions::make_go_home_action([this](auto&) {
|
m_go_home_action = GUI::CommonActions::make_go_home_action([this](auto&) {
|
||||||
m_history.push(help_index_path);
|
m_history.push(help_index_path);
|
||||||
open_page(help_index_path);
|
open_page(help_index_path);
|
||||||
|
|
|
@ -25,8 +25,7 @@ ErrorOr<NonnullRefPtr<PageNode>> Node::try_create_from_query(Vector<StringView,
|
||||||
auto query_parameter_iterator = query_parameters.begin();
|
auto query_parameter_iterator = query_parameters.begin();
|
||||||
|
|
||||||
if (query_parameter_iterator.is_end())
|
if (query_parameter_iterator.is_end())
|
||||||
// BUG! No query was given.
|
return PageNode::help_index_page();
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
|
|
||||||
auto first_query_parameter = *query_parameter_iterator;
|
auto first_query_parameter = *query_parameter_iterator;
|
||||||
++query_parameter_iterator;
|
++query_parameter_iterator;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "PageNode.h"
|
#include "PageNode.h"
|
||||||
#include "SectionNode.h"
|
#include "SectionNode.h"
|
||||||
|
#include <AK/RefPtr.h>
|
||||||
|
|
||||||
namespace Manual {
|
namespace Manual {
|
||||||
|
|
||||||
|
@ -26,4 +27,10 @@ ErrorOr<String> PageNode::path() const
|
||||||
return TRY(String::formatted("{}/{}.md", TRY(m_section->path()), m_page));
|
return TRY(String::formatted("{}/{}.md", TRY(m_section->path()), m_page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<NonnullRefPtr<PageNode>> PageNode::help_index_page()
|
||||||
|
{
|
||||||
|
static NonnullRefPtr<PageNode> const help_index_page = TRY(try_make_ref_counted<PageNode>(sections[7 - 1], TRY(String::from_utf8("Help-index"sv))));
|
||||||
|
return help_index_page;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ public:
|
||||||
|
|
||||||
ErrorOr<String> path() const;
|
ErrorOr<String> path() const;
|
||||||
|
|
||||||
|
static ErrorOr<NonnullRefPtr<PageNode>> help_index_page();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NonnullRefPtr<SectionNode> m_section;
|
NonnullRefPtr<SectionNode> m_section;
|
||||||
String m_page;
|
String m_page;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue