-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: add a global setting to support custom docs url path (#107)
* FEATURE: add a global setting to support custom docs url path This commit adds a GlobalSetting `docs_path` to support custom docs url path for sites that do not want docs page to live at `/docs` and have a customized path. * Fixed the route declaration * Test and linting * Update server.en.yml * Fixed doc test * Fixed linting. * Testing qunit test fix * Fixed tests * Prettified tests * Changed the implementation from SiteSetting to GlobalSetting instead. * Fixed tests * Cleanup * Using Site instead of .js.erb to pass GlobalSetting.docs_url to the front end. Also fixed front end tests * Remove references to obsolete site setting * remove unused fixture file * Rename `docs_url` to `docs_path` and use camelCase in JavaScript * Add serializer tests Co-authored-by: Arpit Jalan <er.ajalan@gmail.com>
- Loading branch information
1 parent
f1dd03f
commit 6b3f257
Showing
16 changed files
with
104 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { getDocs } from "../lib/get-docs"; | ||
|
||
export default function () { | ||
this.route("docs", { path: "/docs" }, function () { | ||
const docsPath = getDocs(); | ||
|
||
this.route("docs", { path: "/" + docsPath }, function () { | ||
this.route("index", { path: "/" }); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<a href="/docs?topic={{topic.id}}" class="docs-topic-link">{{{topic.fancyTitle}}}</a> | ||
<a href="/{{urlPath}}?topic={{topic.id}}" class="docs-topic-link">{{{topic.fancyTitle}}}</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Site from "discourse/models/site"; | ||
|
||
export function getDocs() { | ||
return Site.currentProp("docs_path") || "docs"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe SiteSerializer do | ||
fab!(:user) { Fabricate(:user) } | ||
let(:guardian) { Guardian.new(user) } | ||
|
||
before do | ||
SiteSetting.docs_enabled = true | ||
GlobalSetting.stubs(:docs_path).returns('docs') | ||
end | ||
|
||
it 'returns correct default value' do | ||
data = described_class.new(Site.new(guardian), scope: guardian, root: false).as_json | ||
|
||
expect(data[:docs_path]).to eq("docs") | ||
end | ||
|
||
it 'returns custom path based on global setting' do | ||
GlobalSetting.stubs(:docs_path).returns('custom_path') | ||
data = described_class.new(Site.new(guardian), scope: guardian, root: false).as_json | ||
|
||
expect(data[:docs_path]).to eq("custom_path") | ||
end | ||
end |
Oops, something went wrong.