-
+
+ {{ note.getActorNickname() }} +
diff --git a/public/assets/css/network/public.css b/public/assets/css/network/public.css index 414e7b22e4..ad20551ef1 100644 --- a/public/assets/css/network/public.css +++ b/public/assets/css/network/public.css @@ -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); -} \ No newline at end of file +} + +/* TODO FIX THIS */ +.notes-wrap .note-post { + order: 2; + width: 100%; +} +textarea#form_content { + width: 100%; +} diff --git a/public/assets/css/network/public_mid.css b/public/assets/css/network/public_mid.css index 6ae497a5e8..20ce9c3b7c 100644 --- a/public/assets/css/network/public_mid.css +++ b/public/assets/css/network/public_mid.css @@ -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); -} \ No newline at end of file +} + +/* TODO FIX THIS */ +.notes-wrap .note-post { + order: 2; + width: 100%; +} +textarea#form_content { + width: 100%; +} diff --git a/public/assets/css/network/public_small.css b/public/assets/css/network/public_small.css index 89092713e1..bcbb9f443b 100644 --- a/public/assets/css/network/public_small.css +++ b/public/assets/css/network/public_small.css @@ -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); -} \ No newline at end of file +} + +/* TODO FIX THIS */ +.notes-wrap .note-post { + order: 2; + width: 100%; +} +textarea#form_content { + width: 100%; +} diff --git a/src/Controller/NetworkPublic.php b/src/Controller/NetworkPublic.php index 2183ce12fa..7d5c1b215f 100644 --- a/src/Controller/NetworkPublic.php +++ b/src/Controller/NetworkPublic.php @@ -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, ]; } } diff --git a/src/Entity/Note.php b/src/Entity/Note.php index fcf1a8eb85..2fb7dc936a 100644 --- a/src/Entity/Note.php +++ b/src/Entity/Note.php @@ -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; } } diff --git a/templates/network/public.html.twig b/templates/network/public.html.twig index 0469243a07..36460bfe21 100644 --- a/templates/network/public.html.twig +++ b/templates/network/public.html.twig @@ -22,50 +22,58 @@ {% endblock %} {% block body %} -