Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appearance Changes #53

Merged
merged 5 commits into from
Aug 1, 2018
Merged

Appearance Changes #53

merged 5 commits into from
Aug 1, 2018

Conversation

mattregul
Copy link

  • Now uses weblegends style.css
  • Has own stylesheet (aistyle.css) for df-ai specific items (nav menu & stock report's table)
  • Chopped original nav menu up into chunks (likely over-engineered)
  • Added “Home” link, to return to weblegends homepage

image

- Now uses weblegends style.css
- Has own stylesheet (aistyle.css) for df-ai specific items (nav menu & stock report's table)
- Chopped original nav menu up into chunks (likely over-engineered)
- Added “Home” link, to return to weblegends homepage
Copy link
Owner

@BenLubar BenLubar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the individual comments, can you rebase (or merge) this on top of the master branch? 64e341c is required for the build to work on Linux.

weblegends.cpp Outdated
@@ -14,6 +14,16 @@ extern bool & enabled;

REQUIRE_GLOBAL(world);

enum AIPages {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reformat this to use the DFHack coding style? Basically, { should go on the next line.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, changing this from enum to enum class will stop it from going into the global namespace. Right now, Plan (enum item) conflicts with Plan (class name).

weblegends.cpp Outdated
@@ -35,9 +45,124 @@ std::string html_escape(const std::string & str)
return escaped;
}

std::string getAIPageURL(const int currentPage){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of int, this should use AIPages.

Also, the { should go on the next line to match the DFHack coding style.

weblegends.cpp Outdated
}
}

int getAIPage(const std::string url){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of int, this should use AIPages.

Also, the { should go on the next line to match the DFHack coding style.

weblegends.cpp Outdated
return AIPages::Status;
}

void create_nav_menu(weblegends_handler_v1 & handler, const std::string url)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const std::string url should be changed to const std::string & url to avoid copying the string.

weblegends.cpp Outdated
std::string title;
int currentPage = 0;
// Get current page
currentPage = getAIPage(url);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be AIPages instead of int, and you don't need to assign 0 to the variable before you call the function.

weblegends.cpp Outdated
// return Report;
if (url == "/report/plan")
return AIPages::Report_Plan; // Tasks
else if (url == "/report/population")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since every if in this function returns, you can remove all the elses.

weblegends.cpp Outdated
@@ -14,6 +14,16 @@ extern bool & enabled;

REQUIRE_GLOBAL(world);

enum AIPages {
Status, // Status
//Report, // Report - No longer used
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the Report enum item, even in a comment. It just makes the code messier.

weblegends.cpp Outdated
title = "DF-AI - Status";
}
// Build Nav Menu =========
handler.cp437_out() << "<!DOCTYPE html><html lang=\"en\"><head><title>" << title << "</title><base href=\"../..\"/><link rel=\"stylesheet\" href=\"style.css\"/><link rel=\"stylesheet\" href=\"df-ai/aistyle.css\"/></head>";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<base href="../.."/> should only be used for pages with two slashes in their relative url. <base href=".."/> is for pages like df-ai/version and df-ai/plan, and there should not be a base tag at all for the df-ai status page.

weblegends.cpp Outdated
bool ai_weblegends_handler(weblegends_handler_v1 & handler, const std::string & url)
{
if (url == "/style.css")
// Requesting Sytlesheet
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You spelled Stylesheet wrong here 😛

weblegends.cpp Outdated
if (!enabled || !dwarfAI)
{
handler.status_code() = 503;
handler.status_description() = "Service Unavailable";
handler.cp437_out() << "<!DOCTYPE html><html lang=\"en\"><head><title>df-ai</title></head>";
handler.cp437_out() << "<!DOCTYPE html><html lang=\"en\"><head><title>df-ai - Service Unavailable</title></head>";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service Unavailable is probably too technical for most df-ai users (the previous line is part of the HTTP implementation.) Maybe something like df-ai - not active?

Also, this page does not include any stylesheets. The base tag might be a bit complicated to implement here.

- Removed commented items related to the old "Report"
- switched AIPages to an enum class
- getAIPageURL() now accepts AIPages, was int
- getAIPage() now returns AIPages, was int
- create_nav_menu() is always called now, ensuring styles are included in every page
- - currentPage is now an AIPages instead of int
- - simplified how each of the menu links are built, removing repetitive code
- Reworked displaying the "AI Not active" message when df-ai isn't running
- - Page title is set in create_nav_menu()
- - Added a help message and link to wiki to aid user
- - If df-ai isn't running, clicking on any menu item displays the "not active screen and a help message
- Base url changes depending on your navigation level (status and the "not active" page have a base, so the "Home" menu item returns user to the weblegends menu
- fixed typos
- Added new CSS class "navItem" to each menu item, applying a 12px right padding
- removed " - " between each menu item
@mattregul
Copy link
Author

mattregul commented Aug 1, 2018

I think I did the rebase right?

Appearance Changes - pt2

  • Removed commented items related to the old "Report"
  • switched AIPages to an enum class
  • getAIPageURL() now accepts AIPages, was int
  • getAIPage() now returns AIPages, was int
  • create_nav_menu() is always called now, ensuring styles are included in every page
    • currentPage is now an AIPages instead of int
    • simplified how each of the menu links are built, removing repetitive code
  • Reworked displaying the "AI Not active" message when df-ai isn't running
    • Page title is set in create_nav_menu()
    • Added a help message and link to wiki to aid user
    • If df-ai isn't running, clicking on any menu item displays the "not active screen and a help message
  • Base url changes depending on your navigation level (status and the "not active" page have a base, so the "Home" menu item returns user to the weblegends menu
  • fixed typos
  • Added new CSS class "navItem" to each menu item, applying a 12px right padding
  • removed " - " between each menu item

weblegends.cpp Outdated
title = "DF-AI - Status";
baseURL = "/";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ./ or just an empty string. Otherwise, it's like an infinite number of ../../...

weblegends.cpp Outdated
handler.status_description() = "Service Unavailable";
handler.cp437_out() << "<!DOCTYPE html><html lang=\"en\"><head><title>df-ai - Service Unavailable</title></head>";
handler.cp437_out() << "<body><p><i>AI is not active.</i></p></body></html>";
handler.status_description() = "df-ai - Not Active";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be Service Unavailable. status_description isn't shown to people, it's for the benefit of machines.

- Fixed base for status and "not active" screen
- Fixed "not active" description to "Service Unavailable"
@BenLubar BenLubar merged commit f8b297b into BenLubar:master Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants