[PLUGINS][ProfileColor] Re-organized plugins templates and assets. ProfileColor plugin fixed.

このコミットが含まれているのは:
Eliseu Amaro 2021-09-25 11:17:56 +01:00
コミット 57b94af9f6
28個のファイルの変更72行の追加103行の削除

ファイルの表示

@ -92,6 +92,6 @@ class AnswerPoll
}
}
return ['_template' => 'Poll/respondpoll.html.twig', 'question' => $question, 'form' => $form->createView()];
return ['_template' => 'poll/respondpoll.html.twig', 'question' => $question, 'form' => $form->createView()];
}
}

ファイルの表示

@ -101,6 +101,6 @@ class NewPoll
}
}
return ['_template' => 'Poll/newpoll.html.twig', 'form' => $form->createView()];
return ['_template' => 'poll/newpoll.html.twig', 'form' => $form->createView()];
}
}

ファイルの表示

@ -0,0 +1,18 @@
{% extends 'stdgrid.html.twig' %}
{% block title %}Poll{% endblock %}
{% block body %}
<div class="content">
<div class="poll">
<p class="poll-question">Q. {{ question }}</p>
{% block form %}
<div class='form-single'>
{{ form(form) }}
</div>
{% endblock form %}
</div>
</div>
{% endblock body %}
{% block javascripts %}{% endblock %}

ファイルの表示

@ -60,7 +60,7 @@ class ProfileColor
$pcolor = DB::find('profile_color', ['actor_id' => $actor_id]);
$color = '#000000';
if ($pcolor != null) {
$color = $pcolor->getColor();
$color = $pcolor;
}
$form = Form::create([
@ -73,17 +73,17 @@ class ProfileColor
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
if ($pcolor != null) {
if ($pcolor !== null) {
DB::remove($pcolor);
DB::flush();
}
$pcolor = Entity\ProfileColor::create(['actor_id' => $actor_id, 'color' => $data['color']]);
$pcolor = Entity\ProfileColor::create(['actor_id' => $actor_id, 'profile_color' => $data['color']]);
DB::persist($pcolor);
DB::flush();
throw new RedirectException();
}
return ['_template' => 'profilecolor/profilecolor.html.twig', 'form' => $form->createView()];
return ['_template' => 'profileColor/profileColorSettings.html.twig', 'form' => $form->createView()];
}
}

ファイルの表示

@ -25,6 +25,7 @@ use App\Core\Event;
use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader;
use App\Util\Common;
use App\Util\Formatting;
use Plugin\ProfileColor\Controller as C;
use Symfony\Component\HttpFoundation\Request;
@ -65,39 +66,26 @@ class ProfileColor extends Plugin
return Event::next;
}
/**
* Populate twig vars
*
* @param array $vars
*
* @return bool hook value; true means continue processing, false means stop.
*
* public function onStartTwigPopulateVars(array &$vars): bool
* {
* /*$vars['profile_tabs'][] = [
* 'title' => 'Color',
* 'desc' => 'Change your profile color.',
* 'path' => 'profilecolor/profilecolor.html.twig',
* ];
* if (Common::user() != null) {
* $color = DB::find('profile_color', ['actor_id' => Common::user()->getId()]);
* if ($color != null) {
* $vars['profile_extras'][] = ['name' => 'profilecolor', 'vars' => ['color' => $color->getColor()]];
* }
* }
* return Event::next;
* }*/
/**
* Output our dedicated stylesheet
* Renders profileColorView, which changes the background color of that profile.
*
* @param array $styles stylesheets path
*
* @return bool hook value; true means continue processing, false means stop.
* @param $vars
* @param $res
* @return bool
*/
public function onStartShowStyles(array &$styles): bool
public function onAppendCardProfile(&$res): bool
{
$styles[] = 'profilecolor/profilecolor.css';
$user = Common::user();
if ($user !== null) {
$actor_id = $user->getId();
$color = DB::find('profile_color', ['actor_id' => $actor_id]);
if ($color !== null) {
$res[] = Formatting::twigRenderFile('/profileColor/profileColorView.html.twig', ['profile' => $color]);
}
}
return Event::next;
}
}

ファイルの表示

@ -0,0 +1,7 @@
{% block stylesheets %}
<style>
.profile {
background: {{ profile.color }} !important;
}
</style>
{% endblock stylesheets %}

ファイルの表示

@ -1,16 +0,0 @@
.pcolor {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
.profile-color {
width: 100%;
height: 100%;
background-color: transparent;
box-sizing: border-box;
border: 5px solid;
}

ファイルの表示

@ -34,6 +34,10 @@
{{ '(No tags)' | trans }}
{% endif %}
</nav>
{% for block in handle_event('AppendCardProfile') %}
{{ block | raw }}
{% endfor %}
</section>
<hr>

ファイルの表示

@ -1,3 +1,8 @@
{% block stylesheets %}
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/left/view.css') }}">
{% endblock stylesheets %}
{% block leftpanel %}
<div class="panel panel-left">
<input type="checkbox" id="panel-left-toggle" aria-hidden="true" tabindex="-1">
<label id="panel-left-icon" for="panel-left-toggle" aria-hidden="true" tabindex="-1">{{ icon('menu', 'icon icon-left') | raw }}</label>
@ -17,4 +22,5 @@
{{ block("footer", "cards/navigation/view.html.twig") }}
</aside>
</div>
</div>
{% endblock leftpanel %}

ファイルの表示

@ -1,40 +0,0 @@
{% extends 'stdgrid.html.twig' %}
{% block meta %}
{{ parent() }}
{% endblock %}
{% block title %}Poll{% endblock %}
{% block stylesheets %}
{{ parent() }}
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/network/public.css') }}"
media="screen and (min-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/network/public_mid.css') }}"
media="screen and (max-width: 1300px)">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/network/public_small.css') }}"
media="screen and (max-width: 750px)">
{% endblock %}
{% block header %}
{{ parent() }}
{% endblock %}
{% block left %}
{{ parent() }}
{% endblock %}
{% block body %}
<div class="content">
<div class="poll">
<p class="poll-question">Q. {{ question }}</p>
{% block form %}
<div class='form-single'>
{{ form(form) }}
</div>
{% endblock form %}
</div>
</div>
{% endblock body %}
{% block javascripts %}{% endblock %}

ファイルの表示

@ -1,5 +0,0 @@
<a class="pcolor">
{% if vars is not empty %}
<div class="profile-color" style="border-color: {{ vars.color }}"></div>
{% endif %}
</a>

ファイルの表示

@ -1,3 +1,8 @@
{% block stylesheets %}
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/right/view.css') }}">
{% endblock stylesheets %}
{% block rightpanel %}
<div class="panel panel-right">
<input type="checkbox" id="panel-right-toggle" aria-hidden="true" tabindex="-1">
<label id="panel-right-icon" for="panel-right-toggle" aria-hidden="true" tabindex="-1">{{ icon('notes', 'icon icon-right') | raw }}</label>
@ -51,3 +56,4 @@
</aside>
</div>
{% endblock rightpanel %}

ファイルの表示

@ -9,7 +9,7 @@
{% block stylesheets %}
{{ parent() }}
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/settings.css') }}">
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/settings/view.css') }}">
{% endblock %}
{% block header %}

ファイルの表示

@ -1 +0,0 @@
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/left/left.css') }}">

ファイルの表示

@ -1 +0,0 @@
<link rel='stylesheet' type='text/css' href="{{ asset('assets/css/right/right.css') }}">

ファイルの表示

@ -1,12 +1,15 @@
{% extends '/base.html.twig' %}
{% block stylesheets %}
{{ parent() }}
{% include '/sidepanel/left/left_stylesheets.html.twig' %}
{% include '/sidepanel/right/right_stylesheets.html.twig' %}
{{ block("stylesheets", "/left/view.html.twig") }}
{{ block("stylesheets", "/right/view.html.twig") }}
{% endblock %}
{% block leftpanel %}
{% include '/sidepanel/left/left.html.twig' %}
{% include '/left/view.html.twig' %}
{% endblock %}
{% block rightpanel %}
{% include '/sidepanel/right/right.html.twig' %}
{% include '/right/view.html.twig' %}
{% endblock %}