Просмотр исходного кода

Merge pull request #460 from pixelfed/frontend-ui-refactor

Frontend ui refactor
daniel 6 лет назад
Родитель
Сommit
1bea3bbe15

+ 10 - 0
app/Activity.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Activity extends Model
+{
+    protected $dates = ['processed_at'];
+}

+ 136 - 0
app/Util/ActivityPub/Writer/BaseWriter.php

@@ -0,0 +1,136 @@
+<?php
+
+namespace App\Util\ActivityPub\Writer;
+
+use App\Util\ActivityPub\DiscoverActor;
+
+class BaseWriter {
+
+    protected $context = 'https://www.w3.org/ns/activitystreams';
+    protected $activities = ['Announce','Create','Follow','Like'];
+    protected $audiences = ['public', 'unlisted', 'private', 'direct'];
+    protected $audience = 'public';
+    protected $actors = ['Person'];
+    protected $objects = ['Image','Note'];
+    protected $verb;
+    protected $sourceActivity;
+    protected $activity;
+    protected $profile;
+    protected $to = [];
+    protected $cc = [];
+    protected $bcc = [];
+    protected $response;
+    protected $publishedAt;
+
+    public static function build()
+    {
+        return (new self);
+    }
+
+    public function setContext($context)
+    {
+        $this->context = $context;
+        return $this;
+    }
+
+    public function setActor($profile)
+    {
+        $this->actor = $profile;
+        return $this;
+    }
+
+    public function setActorActivity($activity)
+    {
+        $this->activity = $activity;
+        $this->setPublishedAt($activity->created_at->format('Y-m-d\Th:i:s\Z'));
+        return $this;
+    }
+
+    public function setTo($audience)
+    {
+        $this->to = $audience;
+        return $this;
+    }
+
+    public function setCc($audience)
+    {
+        $this->cc = $audience;
+        return $this;
+    }
+
+    public function setBcc($audience)
+    {
+        $this->bcc = $audience;
+        return $this;
+    }
+
+    public function setPublishedAt($timestamp)
+    {
+        $this->publishedAt = $timestamp;
+        return $this;
+    }
+
+    public function audience($audience)
+    {
+        $this->setAudience($audience);
+        $this->buildAudience();
+        return $this;
+    }
+
+    public function setAudience($audience)
+    {
+        if(in_array($audience, $this->audience)) {
+            $this->audience = $audience;
+        }
+        return $this;
+    }
+
+    public function buildAudience()
+    {
+        switch ($this->audience) {
+          case 'public':
+            $this->to = [
+              $this->context . '#Public'
+            ];
+            $this->cc = [
+              $this->actor->permalink('/followers')
+            ];
+            break;
+
+          case 'unlisted':
+            $this->to = [
+              $this->actor->permalink('/followers')
+            ];
+            $this->cc = [
+              $this->context . '#Public'
+            ];
+            break;
+
+          case 'private':
+            $this->to = [
+              $this->actor->permalink('/followers')
+            ];
+            break;
+          
+          default:
+            # code...
+            break;
+        }
+        return $this;
+    }
+
+    public function get()
+    {
+        return $this->getJson();
+    }
+
+    public function getJson()
+    {
+        return json_encode($this->response);
+    }
+
+    public function getArray()
+    {
+        return $this->response;
+    }
+}

+ 36 - 0
database/migrations/2018_09_11_202435_create_activities_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateActivitiesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('activities', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->bigInteger('to_id')->unsigned()->nullable();
+            $table->bigInteger('from_id')->unsigned()->nullable();
+            $table->string('object_type')->nullable();
+            $table->json('data')->nullable();
+            $table->timestamp('processed_at')->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('activities');
+    }
+}

+ 19 - 0
resources/lang/ar/auth.php

@@ -0,0 +1,19 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Authentication Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are used during authentication for various
+    | messages that we need to display to the user. You are free to modify
+    | these language lines according to your application's requirements.
+    |
+    */
+
+    'failed'   => 'لم نعثر على هذه المعطيات في سجلاتنا.',
+    'throttle' => 'لقد قمت بعدة محاولات. يُرجى إعادة المحاولة لاحقًا بعد مُضيّ :seconds ثوان.',
+
+];

+ 14 - 0
resources/lang/ar/navmenu.php

@@ -0,0 +1,14 @@
+<?php
+
+return [
+
+    'viewMyProfile'  => 'معاينة ملفي الشخصي',
+    'myTimeline'     => 'خيطي الزمني',
+    'publicTimeline' => 'الخيط الزمني العام',
+    'remoteFollow'   => 'المتابَعة عند بُعد',
+    'settings'       => 'الإعدادات',
+    'admin'          => 'المدير',
+    'logout'         => 'خروج',
+    'directMessages' => 'الرسائل المباشرة',
+
+];

+ 10 - 0
resources/lang/ar/notification.php

@@ -0,0 +1,10 @@
+<?php
+
+return [
+
+  'likedPhoto'          => 'أُعجِب بصورتك.',
+  'startedFollowingYou' => 'يُتابِعك الآن.',
+  'commented'           => 'علّق على منشورك.',
+  'mentionedYou'        => 'أشار إليك.',
+
+];

+ 19 - 0
resources/lang/ar/pagination.php

@@ -0,0 +1,19 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Pagination Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are used by the paginator library to build
+    | the simple pagination links. You are free to change them to anything
+    | you want to customize your views to better match your application.
+    |
+    */
+
+    'previous' => '&laquo; التالي',
+    'next'     => 'العودة &raquo;',
+
+];

+ 22 - 0
resources/lang/ar/passwords.php

@@ -0,0 +1,22 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Password Reset Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are the default lines which match reasons
+    | that are given by the password broker for a password update attempt
+    | has failed, such as for an invalid token or invalid new password.
+    |
+    */
+
+    'password' => 'ينبغي أن يكون طول الكلمة السرية أزيَد مِن ستة حروف و تكون نفسها متطابقة.',
+    'reset'    => 'تم إعادة تعيين كلمتك السرية!',
+    'sent'     => 'لقد قمنا بإرسال رسالة مع رابط لإعادة تعيين الكلمة السرية!',
+    'token'    => 'رمز إعادة تعيين الكلمة السرية هذا لم يعد صالحًا.',
+    'user'     => "تعذّر علينا العثور على مستخدِم له عنوان البريد الإلكتروني هذا.",
+
+];

+ 12 - 0
resources/lang/ar/profile.php

@@ -0,0 +1,12 @@
+<?php
+
+return [
+  'emptyTimeline'         => 'لم يقم هذا المستخدِم بنشر أي منشور بعد!',
+  'emptyFollowers'        => 'ليس لهذا المستخدِم متابِعون بعد!',
+  'emptyFollowing'        => 'هذا المستخدِم لا يتابع أحدًا بعد!',
+  'emptySaved'            => 'لم تقم بحفظ أي منشور بعد!',
+  'savedWarning'          => 'لا يمكنك عرض إلا ما قمت بالإحتفاظ به',
+  'privateProfileWarning' => 'هذا الحساب خاص',
+  'alreadyFollow'         => 'أنت تتبع :username?',
+  'loginToSeeProfile'     => 'قصد عرض صوَرهم و فيديوهاتهت.',
+];

+ 7 - 0
resources/lang/ar/timeline.php

@@ -0,0 +1,7 @@
+<?php
+
+return [
+
+  'emptyPersonalTimeline' => 'إنّ خيطك الزمني فارغ.',
+
+];

+ 122 - 0
resources/lang/ar/validation.php

@@ -0,0 +1,122 @@
+<?php
+
+return [
+
+    /*
+    |--------------------------------------------------------------------------
+    | Validation Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines contain the default error messages used by
+    | the validator class. Some of these rules have multiple versions such
+    | as the size rules. Feel free to tweak each of these messages here.
+    |
+    */
+
+    'accepted'             => 'The :attribute must be accepted.',
+    'active_url'           => 'The :attribute is not a valid URL.',
+    'after'                => 'The :attribute must be a date after :date.',
+    'after_or_equal'       => 'The :attribute must be a date after or equal to :date.',
+    'alpha'                => 'The :attribute may only contain letters.',
+    'alpha_dash'           => 'The :attribute may only contain letters, numbers, and dashes.',
+    'alpha_num'            => 'The :attribute may only contain letters and numbers.',
+    'array'                => 'The :attribute must be an array.',
+    'before'               => 'The :attribute must be a date before :date.',
+    'before_or_equal'      => 'The :attribute must be a date before or equal to :date.',
+    'between'              => [
+        'numeric' => 'The :attribute must be between :min and :max.',
+        'file'    => 'The :attribute must be between :min and :max kilobytes.',
+        'string'  => 'The :attribute must be between :min and :max characters.',
+        'array'   => 'The :attribute must have between :min and :max items.',
+    ],
+    'boolean'              => 'The :attribute field must be true or false.',
+    'confirmed'            => 'The :attribute confirmation does not match.',
+    'date'                 => 'The :attribute is not a valid date.',
+    'date_format'          => 'The :attribute does not match the format :format.',
+    'different'            => 'The :attribute and :other must be different.',
+    'digits'               => 'The :attribute must be :digits digits.',
+    'digits_between'       => 'The :attribute must be between :min and :max digits.',
+    'dimensions'           => 'The :attribute has invalid image dimensions.',
+    'distinct'             => 'The :attribute field has a duplicate value.',
+    'email'                => 'The :attribute must be a valid email address.',
+    'exists'               => 'The selected :attribute is invalid.',
+    'file'                 => 'The :attribute must be a file.',
+    'filled'               => 'The :attribute field must have a value.',
+    'image'                => 'The :attribute must be an image.',
+    'in'                   => 'The selected :attribute is invalid.',
+    'in_array'             => 'The :attribute field does not exist in :other.',
+    'integer'              => 'The :attribute must be an integer.',
+    'ip'                   => 'The :attribute must be a valid IP address.',
+    'ipv4'                 => 'The :attribute must be a valid IPv4 address.',
+    'ipv6'                 => 'The :attribute must be a valid IPv6 address.',
+    'json'                 => 'The :attribute must be a valid JSON string.',
+    'max'                  => [
+        'numeric' => 'The :attribute may not be greater than :max.',
+        'file'    => 'The :attribute may not be greater than :max kilobytes.',
+        'string'  => 'The :attribute may not be greater than :max characters.',
+        'array'   => 'The :attribute may not have more than :max items.',
+    ],
+    'mimes'                => 'The :attribute must be a file of type: :values.',
+    'mimetypes'            => 'The :attribute must be a file of type: :values.',
+    'min'                  => [
+        'numeric' => 'The :attribute must be at least :min.',
+        'file'    => 'The :attribute must be at least :min kilobytes.',
+        'string'  => 'The :attribute must be at least :min characters.',
+        'array'   => 'The :attribute must have at least :min items.',
+    ],
+    'not_in'               => 'The selected :attribute is invalid.',
+    'not_regex'            => 'The :attribute format is invalid.',
+    'numeric'              => 'The :attribute must be a number.',
+    'present'              => 'The :attribute field must be present.',
+    'regex'                => 'The :attribute format is invalid.',
+    'required'             => 'The :attribute field is required.',
+    'required_if'          => 'The :attribute field is required when :other is :value.',
+    'required_unless'      => 'The :attribute field is required unless :other is in :values.',
+    'required_with'        => 'The :attribute field is required when :values is present.',
+    'required_with_all'    => 'The :attribute field is required when :values is present.',
+    'required_without'     => 'The :attribute field is required when :values is not present.',
+    'required_without_all' => 'The :attribute field is required when none of :values are present.',
+    'same'                 => 'The :attribute and :other must match.',
+    'size'                 => [
+        'numeric' => 'The :attribute must be :size.',
+        'file'    => 'The :attribute must be :size kilobytes.',
+        'string'  => 'The :attribute must be :size characters.',
+        'array'   => 'The :attribute must contain :size items.',
+    ],
+    'string'               => 'The :attribute must be a string.',
+    'timezone'             => 'The :attribute must be a valid zone.',
+    'unique'               => 'The :attribute has already been taken.',
+    'uploaded'             => 'The :attribute failed to upload.',
+    'url'                  => 'The :attribute format is invalid.',
+
+    /*
+    |--------------------------------------------------------------------------
+    | Custom Validation Language Lines
+    |--------------------------------------------------------------------------
+    |
+    | Here you may specify custom validation messages for attributes using the
+    | convention "attribute.rule" to name the lines. This makes it quick to
+    | specify a specific custom language line for a given attribute rule.
+    |
+    */
+
+    'custom' => [
+        'attribute-name' => [
+            'rule-name' => 'custom-message',
+        ],
+    ],
+
+    /*
+    |--------------------------------------------------------------------------
+    | Custom Validation Attributes
+    |--------------------------------------------------------------------------
+    |
+    | The following language lines are used to swap attribute place-holders
+    | with something more reader friendly such as E-Mail Address instead
+    | of "email". This simply helps us make messages a little cleaner.
+    |
+    */
+
+    'attributes' => [],
+
+];

+ 1 - 1
resources/views/profile/partial/private-info.blade.php

@@ -41,7 +41,7 @@
             @endif
           </p>
           <p class="mb-0 lead">{{$user->bio}}</p>
-          <p class="mb-0"><a href="{{$user->website}}" class="font-weight-bold" rel="external nofollow noopener" target="_blank">{{str_limit($user->website, 30)}}</a></p>
+          <p class="mb-0"><a href="{{$user->website}}" class="font-weight-bold" rel="me external nofollow noopener" target="_blank">{{str_limit($user->website, 30)}}</a></p>
         </div>
       </div>
     </div>

+ 1 - 1
resources/views/profile/partial/user-info.blade.php

@@ -81,7 +81,7 @@
             @endif
           </p>
           <p class="mb-0 lead">{{$user->bio}}</p>
-          <p class="mb-0"><a href="{{$user->website}}" class="font-weight-bold" rel="external nofollow noopener" target="_blank">{{str_limit($user->website, 30)}}</a></p>
+          <p class="mb-0"><a href="{{$user->website}}" class="font-weight-bold" rel="me external nofollow noopener" target="_blank">{{str_limit($user->website, 30)}}</a></p>
         </div>
       </div>
     </div>

+ 5 - 3
resources/views/profile/show.blade.php

@@ -32,11 +32,13 @@
             <div class="square-content" style="background-image: url('{{$status->thumb()}}')"></div>
             <div class="info-overlay-text">
               <h5 class="text-white m-auto font-weight-bold">
-                <span class="pr-4">
-                <span class="far fa-heart fa-lg pr-1"></span> {{$status->likes_count}}
+                <span>
+                  <span class="far fa-heart fa-lg p-2 d-flex-inline"></span>
+                  <span class="d-flex-inline">{{App\Util\Lexer\PrettyNumber::convert($status->likes_count)}}</span>
                 </span>
                 <span>
-                <span class="far fa-comment fa-lg pr-1"></span> {{$status->comments_count}}
+                  <span class="far fa-comment fa-lg p-2 d-flex-inline"></span>
+                  <span class="d-flex-inline">{{App\Util\Lexer\PrettyNumber::convert($status->comments_count)}}</span>
                 </span>
               </h5>
             </div>