mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 12:42:40 +08:00
FEATURE: Allow the user to select a custom home page (#5268)
* Add user_home configuration option * Use the new user_home preference to actually show the right home page * Fix trailing whitespace * Update user_option_serializer.rb * Fix JavaScript default homepage tests * Use an object instead of a giant switch * Remove trailing whitespace * Make the default `user_home` set to `null` instead of `0` * Rename user_home to homepage_id
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
import { escape } from 'pretty-text/sanitizer';
|
||||
|
||||
const homepageSelector = 'meta[name=discourse_current_homepage]';
|
||||
|
||||
export function translateSize(size) {
|
||||
switch (size) {
|
||||
case 'tiny': return 20;
|
||||
@ -349,8 +351,22 @@ export function displayErrorForUpload(data) {
|
||||
}
|
||||
|
||||
export function defaultHomepage() {
|
||||
// the homepage is the first item of the 'top_menu' site setting
|
||||
return Discourse.SiteSettings.top_menu.split("|")[0].split(",")[0];
|
||||
let homepage = null;
|
||||
let elem = _.first($(homepageSelector));
|
||||
if (elem) {
|
||||
homepage = elem.content;
|
||||
}
|
||||
if (!homepage) {
|
||||
homepage = Discourse.SiteSettings.top_menu.split("|")[0].split(",")[0];
|
||||
}
|
||||
return homepage;
|
||||
}
|
||||
|
||||
export function setDefaultHomepage(homepage) {
|
||||
let elem = _.first($(homepageSelector));
|
||||
if (elem) {
|
||||
elem.content = homepage;
|
||||
}
|
||||
}
|
||||
|
||||
export function determinePostReplaceSelection({ selection, needle, replacement }) {
|
||||
|
Reference in New Issue
Block a user