Skip to content

Move HTML page handlers into HtmlServer class - #133

Open
ujjwx1 wants to merge 2 commits into
cscout-project:gsoc-2026from
ujjwx1:gsoc-2026-htmlserver
Open

Move HTML page handlers into HtmlServer class#133
ujjwx1 wants to merge 2 commits into
cscout-project:gsoc-2026from
ujjwx1:gsoc-2026-htmlserver

Conversation

@ujjwx1

@ujjwx1 ujjwx1 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

All HTML page handlers previously scattered as free functions in cscout.cpp now live in html.cpp, encapsulated in HtmlServer.

Testing

All existing tests pass.

Planned for Follow-up

  • Give HtmlServer real CscoutEngine &engine and CscoutOptions &opts constructor members, replacing direct global access in handler bodies.
  • Extract file-saving logic out of write_quit_page into CscoutEngine::save_files() returning a SaveResult struct, so the engine stays free of HTML dependencies and the same method can later serve the REST apply endpoint.
  • Replace register_early_handlers() with register_progress_handlers() which registers a single new JSON endpoint returning analysis status.

ujjwx1 added 2 commits July 4, 2026 03:44
Declares the class skeleton: constructor, register_early_handlers(),
register_handlers(), per-handler private methods, static wrappers,
and graph family static methods.

Assisted-by: Claude Sonnet 4.6 (claude.ai)
Model: claude-sonnet-4-6
Prompt: Write the HtmlServer class declaration for html.h including
public registration methods, private page handler methods, static
wrapper functions for SWILL registration, and static graph handler
methods.
Output: The complete HtmlServer class block added to html.h
Introduce HtmlServer class in html.cpp/html.h to encapsulate
all HTML web UI page handlers previously scattered as free
functions in cscout.cpp.

@dspinellis dspinellis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The HtmlServer class has no state associated with it, so I don't see gaining anything by encapsulating callbacks and utility functions. Plain static C functions should be enough and closer to the original design of SWILL and CScout. This will also make it easier to create a simple polymorphic server in the future that contains the actual functionality needed to differentiate between HTML and REST.

So, before doing mass changes, I recommend to design and prototype a couple of functions that

  • abstract some existing CScout UI functionality (e.g. xiquery_page and one more) without embedding HTML-specific code
  • a way to use these functions to provide both an HTML and a REST interface.

@ujjwx1

ujjwx1 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Hi @dspinellis thank you for the feedback. I understand.

Would identifier_page be a good second candidate alongside xiquery_page, or do you have another in mind?

@dspinellis

Copy link
Copy Markdown
Collaborator

Hi @dspinellis thank you for the feedback. I understand.

Would identifier_page be a good second candidate alongside xiquery_page, or do you have another in mind?

That's the one I had in mind. But I wanted you to think for yourself.

@dspinellis dspinellis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you see the boilerplate in the class definition? It points to a design that can be improved. I leave you to think about it, but we can definitely discuss it if you want, even before our scheduled meeting. Or add in a comment a sketch of the proposed design.

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