mirror of https://github.com/Chocobozzz/PeerTube
Fix default trending algorithm in admin config
parent
5471449f99
commit
15825ef18d
|
@ -44,9 +44,6 @@
|
|||
|
||||
<div class="peertube-select-container">
|
||||
<select id="trendingVideosAlgorithmsDefault" formControlName="default" class="form-control">
|
||||
<option i18n value="publishedAt">Recently added videos</option>
|
||||
<option i18n value="originallyPublishedAt">Original publication date</option>
|
||||
<option i18n value="name">Name</option>
|
||||
<option i18n value="hot">Hot videos</option>
|
||||
<option i18n value="most-viewed">Recent views</option>
|
||||
<option i18n value="most-liked">Most liked videos</option>
|
||||
|
|
|
@ -177,9 +177,6 @@ export class VideosListCommonPageComponent implements OnInit, OnDestroy, Disable
|
|||
case 'best':
|
||||
return '-hot'
|
||||
|
||||
case 'name':
|
||||
return 'name'
|
||||
|
||||
default:
|
||||
return '-' + algorithm as VideoSortField
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import { ServiceWorkerModule } from '@angular/service-worker'
|
|||
import localeOc from '@app/helpers/locales/oc'
|
||||
import { AppRoutingModule } from './app-routing.module'
|
||||
import { AppComponent } from './app.component'
|
||||
import { CoreModule, PluginService, ServerService } from './core'
|
||||
import { CoreModule, PluginService, RedirectService, ServerService } from './core'
|
||||
import { EmptyComponent } from './empty.component'
|
||||
import { HeaderComponent, SearchTypeaheadComponent, SuggestionComponent } from './header'
|
||||
import { HighlightPipe } from './header/highlight.pipe'
|
||||
|
@ -28,13 +28,17 @@ import { SharedUserInterfaceSettingsModule } from './shared/shared-user-settings
|
|||
|
||||
registerLocaleData(localeOc, 'oc')
|
||||
|
||||
export function loadConfigFactory (server: ServerService, pluginService: PluginService) {
|
||||
export function loadConfigFactory (server: ServerService, pluginService: PluginService, redirectService: RedirectService) {
|
||||
const initializeServices = () => {
|
||||
redirectService.init()
|
||||
pluginService.initializePlugins()
|
||||
}
|
||||
|
||||
return () => {
|
||||
const result = server.loadHTMLConfig()
|
||||
if (result) return result.pipe(tap(() => initializeServices()))
|
||||
|
||||
if (result) return result.pipe(tap(() => pluginService.initializePlugins()))
|
||||
|
||||
return pluginService.initializePlugins()
|
||||
initializeServices()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +88,7 @@ export function loadConfigFactory (server: ServerService, pluginService: PluginS
|
|||
{
|
||||
provide: APP_INITIALIZER,
|
||||
useFactory: loadConfigFactory,
|
||||
deps: [ ServerService, PluginService ],
|
||||
deps: [ ServerService, PluginService, RedirectService ],
|
||||
multi: true
|
||||
}
|
||||
]
|
||||
|
|
|
@ -31,12 +31,15 @@ export class RedirectService {
|
|||
private serverService: ServerService,
|
||||
private storage: SessionStorageService
|
||||
) {
|
||||
// The config is first loaded from the cache so try to get the default route
|
||||
|
||||
}
|
||||
|
||||
init () {
|
||||
const config = this.serverService.getHTMLConfig()
|
||||
if (config?.instance?.defaultClientRoute) {
|
||||
if (config.instance.defaultClientRoute) {
|
||||
this.defaultRoute = config.instance.defaultClientRoute
|
||||
}
|
||||
if (config?.trending?.videos?.algorithms?.default) {
|
||||
if (config.trending.videos.algorithms.default) {
|
||||
this.defaultTrendingAlgorithm = config.trending.videos.algorithms.default
|
||||
}
|
||||
|
||||
|
@ -47,7 +50,7 @@ export class RedirectService {
|
|||
|
||||
// Track previous url
|
||||
this.currentUrl = this.router.url
|
||||
router.events.subscribe(event => {
|
||||
this.router.events.subscribe(event => {
|
||||
if (event instanceof NavigationEnd || event instanceof NavigationCancel) {
|
||||
if ([ '/401', '/404' ].includes(event.url)) return
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ export class ServerService {
|
|||
|
||||
loadHTMLConfig () {
|
||||
try {
|
||||
return this.loadHTMLConfigLocally()
|
||||
this.loadHTMLConfigLocally()
|
||||
} catch (err) {
|
||||
// Expected in dev mode since we can't inject the config in the HTML
|
||||
if (environment.production !== false) {
|
||||
|
|
|
@ -236,12 +236,14 @@ open_telemetry:
|
|||
|
||||
trending:
|
||||
videos:
|
||||
interval_days: 7 # Compute trending videos for the last x days
|
||||
interval_days: 7 # Compute trending videos for the last x days for 'most-viewed' algorithm
|
||||
|
||||
algorithms:
|
||||
enabled:
|
||||
- 'hot' # adaptation of Reddit's 'Hot' algorithm
|
||||
- 'most-viewed' # default, used initially by PeerTube as the trending page
|
||||
- 'most-liked'
|
||||
- 'hot' # Adaptation of Reddit's 'Hot' algorithm
|
||||
- 'most-viewed' # Number of views in the last x days
|
||||
- 'most-liked' # Global views since the upload of the video
|
||||
|
||||
default: 'most-viewed'
|
||||
|
||||
# Cache remote videos on your server, to help other instances to broadcast the video
|
||||
|
|
|
@ -234,12 +234,14 @@ open_telemetry:
|
|||
|
||||
trending:
|
||||
videos:
|
||||
interval_days: 7 # Compute trending videos for the last x days
|
||||
interval_days: 7 # Compute trending videos for the last x days for 'most-viewed' algorithm
|
||||
|
||||
algorithms:
|
||||
enabled:
|
||||
- 'hot' # adaptation of Reddit's 'Hot' algorithm
|
||||
- 'most-viewed' # default, used initially by PeerTube as the trending page
|
||||
- 'most-liked'
|
||||
- 'hot' # Adaptation of Reddit's 'Hot' algorithm
|
||||
- 'most-viewed' # Number of views in the last x days
|
||||
- 'most-liked' # Global views since the upload of the video
|
||||
|
||||
default: 'most-viewed'
|
||||
|
||||
# Cache remote videos on your server, to help other instances to broadcast the video
|
||||
|
|
Loading…
Reference in New Issue