[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; transition: all 0.8s ease;
} }
.notices { .notes-wrap {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
font-size: var(--medium-size); font-size: var(--medium-size);
@ -65,13 +65,13 @@
background-color: var(--bg3); background-color: var(--bg3);
padding: var(--unit-size); padding: var(--unit-size);
} }
.notices .timeline-nav { .notes-wrap .timeline-nav {
order: 2; order: 3;
width: 100%; width: 100%;
box-shadow: var(--shadow); box-shadow: var(--shadow);
border-radius: var(--unit-size); border-radius: var(--unit-size);
} }
.notices .timeline-nav .notices div { .notes-wrap .timeline-nav .notes div {
background-color: var(--bg4); background-color: var(--bg4);
box-shadow: var(--shadow); box-shadow: var(--shadow);
padding: var(--unit-size); padding: var(--unit-size);
@ -79,7 +79,16 @@
border-radius: var(--unit-size); border-radius: var(--unit-size);
width: 100%; width: 100%;
} }
.notices .main-nav { .notes-wrap .main-nav {
width: 100%; width: 100%;
font-size: var(--unit-size); 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; transition: all 0.8s ease;
} }
.notices { .notes-wrap {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
font-size: var(--medium-size); font-size: var(--medium-size);
@ -65,13 +65,13 @@
background-color: var(--bg3); background-color: var(--bg3);
padding: var(--unit-size); padding: var(--unit-size);
} }
.notices .timeline-nav { .notes-wrap .timeline-nav {
order: 2; order: 2;
width: 100%; width: 100%;
box-shadow: var(--shadow); box-shadow: var(--shadow);
border-radius: var(--unit-size); border-radius: var(--unit-size);
} }
.notices .timeline-nav .notices div { .notes-wrap .timeline-nav .notices div {
background-color: var(--bg4); background-color: var(--bg4);
box-shadow: var(--shadow); box-shadow: var(--shadow);
padding: var(--unit-size); padding: var(--unit-size);
@ -79,7 +79,16 @@
border-radius: var(--unit-size); border-radius: var(--unit-size);
width: 100%; width: 100%;
} }
.notices .main-nav { .notes-wrap .main-nav {
width: 100%; width: 100%;
font-size: var(--unit-size); 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; transition: all 0.8s ease;
} }
.notices { .notes-wrap {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
font-size: var(--medium-size); font-size: var(--medium-size);
@ -65,13 +65,13 @@
background-color: var(--bg3); background-color: var(--bg3);
padding: 2%; padding: 2%;
} }
.notices .timeline-nav { .notes-wrap .timeline-nav {
order: 2; order: 2;
width: 100%; width: 100%;
box-shadow: var(--shadow); box-shadow: var(--shadow);
border-radius: var(--unit-size); border-radius: var(--unit-size);
} }
.notices .timeline-nav .notices div { .notes-wrap .timeline-nav .notices div {
background-color: var(--bg4); background-color: var(--bg4);
box-shadow: var(--shadow); box-shadow: var(--shadow);
padding: var(--unit-size); padding: var(--unit-size);
@ -79,7 +79,16 @@
border-radius: var(--unit-size); border-radius: var(--unit-size);
width: 100%; width: 100%;
} }
.notices .main-nav { .notes-wrap .main-nav {
width: 100%; width: 100%;
font-size: var(--unit-size); 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; namespace App\Controller;
use App\Core\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 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 [ return [
'_template' => 'network/public.html.twig', '_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; namespace App\Entity;
use App\Core\DB\DB;
use App\Core\Entity;
use DateTimeInterface; use DateTimeInterface;
/** /**
@ -33,7 +35,7 @@ use DateTimeInterface;
* @copyright 2020 Free Software Foundation, Inc http://www.fsf.org * @copyright 2020 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/ */
class Note class Note extends Entity
{ {
// {{{ Autocode // {{{ Autocode
@ -172,9 +174,14 @@ class Note
// }}} Autocode // }}} Autocode
public function getActorNickname()
{
return DB::find('gsactor', $this->gsactor_id)->getNickname();
}
public static function schemaDef(): array public static function schemaDef(): array
{ {
$def = [ return [
'name' => 'note', 'name' => 'note',
'fields' => [ 'fields' => [
'id' => ['type' => 'serial', 'not null' => true], 'id' => ['type' => 'serial', 'not null' => true],
@ -207,7 +214,5 @@ class Note
], ],
'fulltext indexes' => ['notice_fulltext_idx' => ['content']], 'fulltext indexes' => ['notice_fulltext_idx' => ['content']],
]; ];
return $def;
} }
} }

View File

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