diff --git a/app/controllers/docs_controller.rb b/app/controllers/docs_controller.rb index cefc25c08..6e69b23c1 100644 --- a/app/controllers/docs_controller.rb +++ b/app/controllers/docs_controller.rb @@ -1,6 +1,8 @@ class DocsController < InertiaController layout "inertia" + inertia_share docs_nav: -> { docs_nav_props } + POPULAR_EDITORS = [ [ "VS Code", "vs-code" ], [ "PyCharm", "pycharm" ], [ "IntelliJ IDEA", "intellij-idea" ], [ "Sublime Text", "sublime-text" ], [ "Vim", "vim" ], [ "Neovim", "neovim" ], @@ -104,6 +106,36 @@ def show private + def docs_nav_props + current_path = request.path + { + current_path: current_path, + home_url: docs_path, + api_docs_url: "/api-docs", + github_url: "https://github.com/hackclub/hackatime", + slack_url: "https://hackclub.slack.com/archives/C07MQ845X1F", + sections: [ + { + title: "Getting Started", + links: [ + { label: "Quick Start", href: doc_path("getting-started/quick-start") }, + { label: "Installation", href: doc_path("getting-started/installation") }, + { label: "Configuration", href: doc_path("getting-started/configuration") } + ] + }, + { + title: "Developers", + links: [ + { label: "API Docs", href: "/api-docs/" }, + { label: "OAuth Apps", href: doc_path("oauth/oauth-apps") } + ] + } + ], + popular_editors: POPULAR_EDITORS, + all_editors: ALL_EDITORS + } + end + def sanitize_path(path) # Remove any directory traversal attempts and normalize path return "index" if path.blank? diff --git a/app/controllers/extensions_controller.rb b/app/controllers/extensions_controller.rb deleted file mode 100644 index a17528106..000000000 --- a/app/controllers/extensions_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ExtensionsController < InertiaController - layout "inertia" - - def index - render inertia: "Extensions/Index" - end -end diff --git a/app/controllers/inertia_controller.rb b/app/controllers/inertia_controller.rb index 1a5f2a6fd..aa889a779 100644 --- a/app/controllers/inertia_controller.rb +++ b/app/controllers/inertia_controller.rb @@ -71,13 +71,13 @@ def inertia_primary_links if current_user links << inertia_link("Projects", my_projects_path, active: request.path.start_with?("/my/projects"), inertia: true) links << inertia_link("Docs", docs_path, active: helpers.current_page?(docs_path) || request.path.start_with?("/docs"), inertia: true) - links << inertia_link("Extensions", extensions_path, active: helpers.current_page?(extensions_path), inertia: true) + links << inertia_link("Setup", my_wakatime_setup_path, active: helpers.current_page?(my_wakatime_setup_path), inertia: true) links << inertia_link("Settings", my_settings_path, active: request.path.start_with?("/my/settings"), inertia: true) links << inertia_link("My OAuth Apps", oauth_applications_path, active: helpers.current_page?(oauth_applications_path) || request.path.start_with?("/oauth/applications"), inertia: true) links << { label: "Logout", action: "logout" } else links << inertia_link("Docs", docs_path, active: helpers.current_page?(docs_path) || request.path.start_with?("/docs"), inertia: true) - links << inertia_link("Extensions", extensions_path, active: helpers.current_page?(extensions_path), inertia: true) + links << inertia_link("Setup", my_wakatime_setup_path, active: helpers.current_page?(my_wakatime_setup_path), inertia: true) end links diff --git a/app/helpers/extensions_helper.rb b/app/helpers/extensions_helper.rb deleted file mode 100644 index 383b12c96..000000000 --- a/app/helpers/extensions_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ExtensionsHelper -end diff --git a/app/javascript/layouts/AppLayout.svelte b/app/javascript/layouts/AppLayout.svelte index 4a8dc081e..e1b1d7bcb 100644 --- a/app/javascript/layouts/AppLayout.svelte +++ b/app/javascript/layouts/AppLayout.svelte @@ -153,8 +153,7 @@ const navLinkWithToolClass = (link: NavLink, toolClass = "") => `${navLinkClass(link.active)}${toolClass ? ` ${toolClass}` : ""}`; - const isLongCachedLink = (link: NavLink) => - link.label === "Docs" || link.label === "Extensions"; + const isLongCachedLink = (link: NavLink) => link.label === "Docs"; const linkCacheFor = (link: NavLink): string | [string, string] => isLongCachedLink(link) ? "10m" : ["0s", "30s"]; diff --git a/app/javascript/layouts/DocsLayout.svelte b/app/javascript/layouts/DocsLayout.svelte new file mode 100644 index 000000000..f393ae939 --- /dev/null +++ b/app/javascript/layouts/DocsLayout.svelte @@ -0,0 +1,311 @@ + + + + + + + + +
+
+ {@render children?.()} +
+
+ + diff --git a/app/javascript/pages/Docs/Index.svelte b/app/javascript/pages/Docs/Index.svelte index 98ea3b0d8..3dc6b625b 100644 --- a/app/javascript/pages/Docs/Index.svelte +++ b/app/javascript/pages/Docs/Index.svelte @@ -1,3 +1,8 @@ + + @@ -18,170 +30,133 @@ /> -
-
-

Documentation

-

- Free, open-source time tracking for Hack Club. Like WakaTime, but free. -

-
+ +
+

Docs

+

+ Learn how to use Hackatime, the open-source time tracking tool from Hack + Club. +

+
-
- - - - + +
+ +

Quick Start

-

- Set up in under a minute +

+ Personalised setup for your editor in under a minute.

- +
+ - - - - + +

Installation

-

Add to your editor

- +

+ Step-by-step instructions for every supported editor. +

+
+ - - - - -

API Docs

-

Interactive reference

-
+ +
+

API Reference

+

+ Interactive Swagger reference for the public API. +

+
+
- - - - + +

OAuth Apps

-

Build integrations

- -
+

+ Build integrations on top of Hackatime's OAuth provider. +

+
+ + -

- Popular Editors -

-
+ +
+
+

Popular editors

+
+ {popular_editors.length} of {all_editors.length} +
+
+
{#each popular_editors as [name, slug]} - + {name} - {name} +
{name}
{/each}
+
-
- +
+ +
+ Browse all {all_editors.length} supported editors +
+ - All {all_editors.length} supported editors - - + +
+
+ {#each all_editors as [name, slug]} + + {name} - -
-
- {#each all_editors as [name, slug]} - - {name} - {name} - - {/each} -
-
+
{name}
+ + {/each} +
+ -
-

- Need help? Ask in - #hackatime-help - on Slack or - open an issue - on GitHub. -

+ +
+ diff --git a/app/javascript/pages/Docs/Show.svelte b/app/javascript/pages/Docs/Show.svelte index 8db2e959e..76f8d4b1b 100644 --- a/app/javascript/pages/Docs/Show.svelte +++ b/app/javascript/pages/Docs/Show.svelte @@ -1,21 +1,57 @@ + + @@ -27,92 +63,52 @@ -
-
- - + + - -
- {@html rendered_content} -
+ +
+ {@html rendered_content} +
- -
+
-
-
+ + + Edit on GitHub + + diff --git a/app/javascript/pages/Extensions/Index.svelte b/app/javascript/pages/Extensions/Index.svelte deleted file mode 100644 index 2350af619..000000000 --- a/app/javascript/pages/Extensions/Index.svelte +++ /dev/null @@ -1,93 +0,0 @@ - - - - Extensions - Hackatime - - -
-
-

Extensions

-

- Third-party tools created by the community. - - * Not guaranteed to work. - -

-
- -
- {#each EXTENSIONS as extension} -
-
-

- {extension.name} -

-
- -

- {extension.description} -

- - -
- {/each} -
-