[Cover] Started implementing Cover plugin: base class, route, base templates, added tabs in profile template

This commit is contained in:
Daniel 2020-11-24 16:47:07 +00:00 committed by Hugo Sales
parent f18a2a4bb6
commit 7739518717
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
5 changed files with 151 additions and 3 deletions

View File

@ -0,0 +1,42 @@
<?php
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
namespace Plugin\Cover\Controller;
use App\Core\Form;
use function App\Core\I18n\_m;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
class Cover
{
public function cover(Request $request)
{
$form = Form::create([
['cover', FileType::class, ['label' => _m('Cover'), 'help' => _m('You can upload your personal cover. The maximum file size is 2MB.')]],
['hidden', HiddenType::class, []],
['save', SubmitType::class, ['label' => _m('Submit')]],
]);
return ['_template' => 'Cover/cover.html.twig', 'form' => $form->createView()];
}
}

75
plugins/Cover/Cover.php Normal file
View File

@ -0,0 +1,75 @@
<?php
// {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}}
namespace Plugin\Cover;
use App\Core\Event;
use App\Core\Module;
use App\Core\Router\RouteLoader;
class Cover extends Module
{
/**
* Map URLs to actions
*
* @param RouteLoader $r
*
* @return bool hook value; true means continue processing, false means stop.
*/
public function onAddRoute(RouteLoader $r): bool
{
$r->connect('settings_cover', 'settings/cover', [Controller\Cover::class, 'cover']);
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['tabs'] = [['title' => 'Poll',
'href' => 'newpoll',
]];
*/
$vars['profile_tabs'] = [['title' => 'Cover',
'href' => 'settings_cover',
]];
return Event::next;
}
/**
* Output our dedicated stylesheet
*
* @param array $styles stylesheets path
*
* @return bool hook value; true means continue processing, false means stop.
*/
public function onStartShowStyles(array &$styles): bool
{
//$styles[] = 'poll/poll.css';
return Event::next;
}
}

View File

@ -0,0 +1,26 @@
{% extends 'settings/profile.html.twig' %}
{% block title %}Cover Settings{% endblock %}
{% block stylesheets %}
{{ parent() }}
<link href="{{ asset('assets/javascript/cropperjs/dist/cropper.css') }}" rel="stylesheet">
<script src="{{ asset('assets/javascript/cropperjs/dist/cropper.js') }}"></script>
{% endblock %}
{% block body %}
{{ parent() }}
{% endblock body %}
{% block form %}
<div class='form'>
{{ form(form) }}
<div id="img-container">
<img id="img-cropped">
</div>
</div>
{% endblock form %}
{% block javascripts %}
<script type="text/javascript" src="{{ asset('assets/javascript/cropping.js') }}"></script>
{% endblock javascripts %}

View File

@ -0,0 +1,3 @@
<div class="Cover">
</div>

View File

@ -13,9 +13,6 @@
{% block secundary_nav %}
<nav class='set-nav'>
<ul>
{# {% for tab in tabs %} #}
{# {% endfor %} #}
<li>
<a href="{{ path('settings_personal_info') }}"
class='hover-effect {{ active('settings_personal_info') }}'>Personal Info</a>
@ -23,6 +20,11 @@
<li>
<a href="{{ path('settings_avatar') }}" class='hover-effect {{ active('settings_avatar') }}'>Avatar</a>
</li>
{% for tab in profile_tabs %}
<li>
<a href="{{ path(tab['href']) }}" class='hover-effect {{ active(tab['href']) }}' >{{ tab['title'] }}</a>
</li>
{% endfor %}
</ul>
</nav>
{% endblock secundary_nav %}