ui: Handle exercice image
This commit is contained in:
parent
ab23ef8f71
commit
1a8ebcb8bf
@ -7,7 +7,19 @@
|
||||
} from 'sveltestrap';
|
||||
|
||||
import { challengeInfo } from '$lib/stores/challengeinfo';
|
||||
import { current_exercice } from '$lib/stores/exercices';
|
||||
import { current_theme } from '$lib/stores/themes';
|
||||
|
||||
let heading_image = "";
|
||||
$: if ($current_theme) {
|
||||
if ($current_exercice && $current_exercice.image) {
|
||||
heading_image = $current_exercice.image;
|
||||
} else {
|
||||
heading_image = $current_theme.image;
|
||||
}
|
||||
} else {
|
||||
heading_image = "";
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@ -27,7 +39,7 @@
|
||||
</Alert>
|
||||
</Container>
|
||||
{:else}
|
||||
<div style="background-image: url({$current_theme.image})" class="page-header">
|
||||
<div style="background-image: url({heading_image})" class="page-header">
|
||||
<Container class="text-primary">
|
||||
<h1 class="display-2">
|
||||
<a href="{$current_theme.urlid}">{$current_theme.name}</a>
|
||||
|
@ -13,6 +13,7 @@ type exportedExercice struct {
|
||||
Id int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Headline string `json:"headline,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
URLId string `json:"urlid"`
|
||||
Tags []string `json:"tags"`
|
||||
Gain int64 `json:"gain"`
|
||||
@ -53,11 +54,17 @@ func ExportThemes() (interface{}, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
exoimgpath := ""
|
||||
if len(exercice.Image) > 0 {
|
||||
exoimgpath = path.Join(FilesDir, exercice.Image)
|
||||
}
|
||||
|
||||
tags, _ := exercice.GetTags()
|
||||
exos = append(exos, exportedExercice{
|
||||
exercice.Id,
|
||||
exercice.Title,
|
||||
exercice.Headline,
|
||||
exoimgpath,
|
||||
exercice.URLId,
|
||||
tags,
|
||||
int64(float64(exercice.Gain) * GlobalScoreCoefficient),
|
||||
|
Loading…
x
Reference in New Issue
Block a user