[STREAM][NetworkPublic] Add skeleton of public timeline and posting

This commit is contained in:
Hugo Sales 2020-08-15 05:47:45 +00:00 committed by Hugo Sales
parent a2269f5745
commit eb138ebdae
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
6 changed files with 134 additions and 69 deletions

View File

@ -57,7 +57,7 @@
transition: all 0.8s ease;
}
.notices {
.notes-wrap {
display: flex;
flex-wrap: wrap;
font-size: var(--medium-size);
@ -65,13 +65,13 @@
background-color: var(--bg3);
padding: var(--unit-size);
}
.notices .timeline-nav {
order: 2;
.notes-wrap .timeline-nav {
order: 3;
width: 100%;
box-shadow: var(--shadow);
border-radius: var(--unit-size);
}
.notices .timeline-nav .notices div {
.notes-wrap .timeline-nav .notes div {
background-color: var(--bg4);
box-shadow: var(--shadow);
padding: var(--unit-size);
@ -79,7 +79,16 @@
border-radius: var(--unit-size);
width: 100%;
}
.notices .main-nav {
.notes-wrap .main-nav {
width: 100%;
font-size: var(--unit-size);
}
}
/* TODO FIX THIS */
.notes-wrap .note-post {
order: 2;
width: 100%;
}
textarea#form_content {
width: 100%;
}

View File

@ -57,7 +57,7 @@
transition: all 0.8s ease;
}
.notices {
.notes-wrap {
display: flex;
flex-wrap: wrap;
font-size: var(--medium-size);
@ -65,13 +65,13 @@
background-color: var(--bg3);
padding: var(--unit-size);
}
.notices .timeline-nav {
.notes-wrap .timeline-nav {
order: 2;
width: 100%;
box-shadow: var(--shadow);
border-radius: var(--unit-size);
}
.notices .timeline-nav .notices div {
.notes-wrap .timeline-nav .notices div {
background-color: var(--bg4);
box-shadow: var(--shadow);
padding: var(--unit-size);
@ -79,7 +79,16 @@
border-radius: var(--unit-size);
width: 100%;
}
.notices .main-nav {
.notes-wrap .main-nav {
width: 100%;
font-size: var(--unit-size);
}
}
/* TODO FIX THIS */
.notes-wrap .note-post {
order: 2;
width: 100%;
}
textarea#form_content {
width: 100%;
}

View File

@ -57,7 +57,7 @@
transition: all 0.8s ease;
}
.notices {
.notes-wrap {
display: flex;
flex-wrap: wrap;
font-size: var(--medium-size);
@ -65,13 +65,13 @@
background-color: var(--bg3);
padding: 2%;
}
.notices .timeline-nav {
.notes-wrap .timeline-nav {
order: 2;
width: 100%;
box-shadow: var(--shadow);
border-radius: var(--unit-size);
}
.notices .timeline-nav .notices div {
.notes-wrap .timeline-nav .notices div {
background-color: var(--bg4);
box-shadow: var(--shadow);
padding: var(--unit-size);
@ -79,7 +79,16 @@
border-radius: var(--unit-size);
width: 100%;
}
.notices .main-nav {
.notes-wrap .main-nav {
width: 100%;
font-size: var(--unit-size);
}
}
/* TODO FIX THIS */
.notes-wrap .note-post {
order: 2;
width: 100%;
}
textarea#form_content {
width: 100%;
}

View File

@ -31,19 +31,44 @@
namespace App\Controller;
use App\Core\Controller;
use App\Core\DB\DB;
use App\Core\Form;
use function App\Core\I18n\_m;
use App\Entity\Note;
use App\Util\Common;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\HttpFoundation\Request;
class NetworkPublic extends Controller
{
public function onPost()
public function handle(Request $request)
{
return ['notices' => ['some notice', 'some other notice', 'some other more diferent notice']];
}
$form = Form::create([
['content', TextareaType::class, ['label' => ' ']],
['send', SubmitType::class, ['label' => _m('Send')]],
]);
$form->handleRequest($request);
if ($form->isSubmitted()) {
$data = $form->getData();
if ($form->isValid()) {
$content = $data['content'];
$id = Common::actor()->getId();
$note = Note::create(['gsactor_id' => $id, 'content' => $content]);
DB::persist($note);
DB::flush();
} else {
// TODO Display error
}
}
$notes = DB::findBy('note', [], ['created' => 'DESC']);
public function handle()
{
return [
'_template' => 'network/public.html.twig',
'notices' => ['some notice', 'some other notice', 'some other more diferent notice'],
'post_form' => $form->createView(),
'notes' => $notes,
];
}
}

View File

@ -21,6 +21,8 @@
namespace App\Entity;
use App\Core\DB\DB;
use App\Core\Entity;
use DateTimeInterface;
/**
@ -33,7 +35,7 @@ use DateTimeInterface;
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class Note
class Note extends Entity
{
// {{{ Autocode
@ -172,9 +174,14 @@ class Note
// }}} Autocode
public function getActorNickname()
{
return DB::find('gsactor', $this->gsactor_id)->getNickname();
}
public static function schemaDef(): array
{
$def = [
return [
'name' => 'note',
'fields' => [
'id' => ['type' => 'serial', 'not null' => true],
@ -207,7 +214,5 @@ class Note
],
'fulltext indexes' => ['notice_fulltext_idx' => ['content']],
];
return $def;
}
}

View File

@ -22,50 +22,58 @@
{% endblock %}
{% block body %}
<div class="content">
<div class="main">
<nav class='main-nav'>
<ul>
<li>
<a href="{{ path('main_all') }}" class='hover-effect {{ active('main_all') }}'>Timeline</a>
</li>
<li>
<a href="#">Groups</a>
</li>
<li>
<a href="#">People</a>
</li>
</ul>
</nav>
<hr>
<div class="notices">
<nav class='main-nav'>
<ul>
<li>
<a href="{{ path('main_all') }}" class='hover-effect {{ active('main_all') }}'>Public</a>
</li>
<li>
<a href="#">Home</a>
</li>
<li>
<a href="#">Network</a>
</li>
</ul>
</nav>
<div class="timeline-nav">
<div class="notices">
{% if notices is defined %}
{% for notice in notices %}
<div> {{notice}} </div>
{% endfor %}
{% else %}
No notices here.
{% endif %}
</div>
</div>
</div>
<div class="content">
<div class="main">
<nav class='main-nav'>
<ul>
<li>
<a href="{{ path('main_all') }}" class='hover-effect {{ active('main_all') }}'>Timeline</a>
</li>
<li>
<a href="#">Groups</a>
</li>
<li>
<a href="#">People</a>
</li>
</ul>
</nav>
<hr>
<div class="notes-wrap">
<nav class='main-nav'>
<ul>
<li>
<a href="{{ path('main_all') }}" class='hover-effect {{ active('main_all') }}'>Public</a>
</li>
<li>
<a href="#">Home</a>
</li>
<li>
<a href="#">Network</a>
</li>
</ul>
</nav>
<div class="note-post">
{{ form(post_form) }}
</div>
</div>
<div class="timeline-nav">
<div class="notes">
{% if notes is defined %}
{% for note in notes %}
<div>
{{ note.getContent() }}
<br>
{{ note.getActorNickname() }}
</div>
{% endfor %}
{% else %}
{{ 'No notes here.' | trans }}
{% endif %}
</div>
</div>
</div>
</hr>
</div>
</div>
{% endblock body %}
{% block javascripts %}{% endblock %}