Add Footer Block options to make_block
This commit is contained in:
parent
19d77064b0
commit
efb2a51216
9 changed files with 185 additions and 12 deletions
|
|
@ -46,14 +46,6 @@
|
|||
<a href="{{ .Info.URL }}" target="_blank" rel="noopener noreferrer">{{ .Info.URL }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Docker Base Image
|
||||
</td>
|
||||
<td>
|
||||
<code>{{ .Instance.GetDockerBaseImage }}</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Running
|
||||
|
|
@ -137,6 +129,56 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pure-u-1 pure-u-xl-2-5">
|
||||
<div class="padding">
|
||||
<div class="overflow">
|
||||
<table class="pure-table pure-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
Drupal Info
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
Theme
|
||||
</td>
|
||||
<td>
|
||||
<code>{{ .Info.Theme }}</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Docker Base Image
|
||||
</td>
|
||||
<td>
|
||||
<code>{{ .Instance.System.GetDockerBaseImage }}</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
OPCache Development Config
|
||||
</td>
|
||||
<td>
|
||||
<code>{{ .Instance.System.OpCacheDevelopment }}</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Content Security Policy
|
||||
</td>
|
||||
<td>
|
||||
<code>{{ .Instance.System.ContentSecurityPolicy }}</code>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pure-u-1 pure-u-xl-2-5">
|
||||
<div class="padding">
|
||||
<div class="overflow">
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ type WissKI struct {
|
|||
LastUpdate time.Time
|
||||
LastCron time.Time
|
||||
|
||||
// current theme
|
||||
Theme string
|
||||
|
||||
// Statistics of the WissKI
|
||||
Statistics Statistics
|
||||
|
||||
|
|
|
|||
|
|
@ -34,3 +34,8 @@ func (blocks *Blocks) Create(ctx context.Context, server *phpx.Server, block Blo
|
|||
err = blocks.Dependencies.PHP.ExecScript(ctx, server, nil, blocksPHP, "create_basic_block", block.Info, block.Content, block.Region, block.BlockID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (blocks *Blocks) GetFooterRegion(ctx context.Context, server *phpx.Server) (region string, err error) {
|
||||
err = blocks.Dependencies.PHP.ExecScript(ctx, server, ®ion, blocksPHP, "get_footer_region")
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,4 +33,33 @@ function create_basic_block(string $info, string $html, string $region, string $
|
|||
'weight' => 0,
|
||||
]);
|
||||
$block->save();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** get_footer_region returns the region that implements the footer */
|
||||
function get_footer_region(): string {
|
||||
$footer_block_map = [
|
||||
"teriyaki" => "footer_bottom",
|
||||
"olivero" => "footer_bottom",
|
||||
"bartik" => "footer_fifth",
|
||||
"ffbartik" => "footer_fifth",
|
||||
"dxpr_theme" => "footer",
|
||||
"bootstrap" => "footer",
|
||||
"bootstrap4" => "footer",
|
||||
"bootstrap5" => "footer",
|
||||
"bootstrap_for_drupal" => "footer_sub_center",
|
||||
"bootstrap_for_drupal_subtheme" => "footer_sub_center",
|
||||
"roma_theme" => "footer_fifth",
|
||||
"gnm2018" => "footer",
|
||||
"oin_graphik" => "footer",
|
||||
"oin_paleo" => "footer",
|
||||
"oin_projekt" => "footer",
|
||||
];
|
||||
|
||||
$theme = \Drupal::service('theme.manager')->getActiveTheme();
|
||||
if (!$theme) {
|
||||
return "";
|
||||
}
|
||||
return $footer_block_map[$theme->getName()] ?? ""; // return the theme
|
||||
}
|
||||
41
internal/wisski/ingredient/php/extras/theme.go
Normal file
41
internal/wisski/ingredient/php/extras/theme.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package extras
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/phpx"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/status"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php"
|
||||
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
// Prefixes implements reading and writing prefix
|
||||
type Theme struct {
|
||||
ingredient.Base
|
||||
Dependencies struct {
|
||||
PHP *php.PHP
|
||||
}
|
||||
}
|
||||
|
||||
//go:embed theme.php
|
||||
var themePHP string
|
||||
|
||||
// Get returns the currently active theme
|
||||
func (t *Theme) Get(ctx context.Context, server *phpx.Server) (theme string, err error) {
|
||||
err = t.Dependencies.PHP.ExecScript(
|
||||
ctx, server, &theme, themePHP,
|
||||
"get_active_theme",
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
func (t *Theme) Fetch(flags ingredient.FetcherFlags, info *status.WissKI) (err error) {
|
||||
if flags.Quick {
|
||||
return
|
||||
}
|
||||
|
||||
info.Theme, _ = t.Get(flags.Context, flags.Server)
|
||||
return
|
||||
}
|
||||
14
internal/wisski/ingredient/php/extras/theme.php
Normal file
14
internal/wisski/ingredient/php/extras/theme.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Gets the actve theme of this WissKI
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_active_theme(): string {
|
||||
$theme = \Drupal::service('theme.manager')->getActiveTheme();
|
||||
if (!$theme) {
|
||||
return "";
|
||||
}
|
||||
return $theme->getName();
|
||||
}
|
||||
|
|
@ -122,6 +122,7 @@ func (wisski *WissKI) allIngredients() []initFunc {
|
|||
auto[*extras.Blocks],
|
||||
auto[*extras.Requirements],
|
||||
auto[*extras.Adapters],
|
||||
auto[*extras.Theme],
|
||||
auto[*users.Users],
|
||||
auto[*users.UserPolicy],
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue