Bläddra i källkod

新增显示作者信息

Moell 9 år sedan
förälder
incheckning
302211999d

+ 10 - 0
app/Presenters/UserPresenter.php

@@ -38,4 +38,14 @@ class UserPresenter extends FractalPresenter
             return $user->name;
         }
     }
+
+    public function getUserInfo($userId = 0) {
+        $columns = ['id', 'name', 'user_pic'];
+
+        if ($userId > 0) {
+            return $this->user->find($userId, $columns);
+        }
+        return $this->user->first($columns);
+
+    }
 }

+ 14 - 6
public/default/css/index.css

@@ -184,10 +184,6 @@
     word-break:break-all;
 }
 
-#moell-home .text-inner a {
-    //color: rgba(255, 255, 255, 0.8);
-    color: #000000;
-}
 
 #moell-home .text-inner h1 {
     font-size: 40px;
@@ -259,7 +255,19 @@
 
 #footer {
     border-top:1px solid #ddd;
-    margin-top:40px;
+    margin-top:20px;
     height:60px;
-    background-color: #ffffff;
+    background-color: #fafafa;
+}
+
+.author .author-footer{
+    margin-top:20px;
 }
+
+.author .author-avatar {
+    max-width:150px;
+}
+
+.author .author-footer a {
+    color: #000000;
+}

+ 34 - 0
resources/views/default/author.blade.php

@@ -0,0 +1,34 @@
+<div class="panel panel-default author">
+    @inject('userPresenter', 'App\Presenters\UserPresenter')
+    <?php
+        $author = isset($user->id) ? $user : $userPresenter->getUserInfo();
+    ?>
+    <div class="panel-heading">
+        <h3 class="panel-title">作者:&nbsp;{{ $author->name }}</h3>
+    </div>
+    <div class="panel-body">
+        <div class="row text-center">
+            <img src="{{ asset('uploads/avatar')."/".$author->user_pic }}" class="img-circle author-avatar" alt="User Image">
+        </div>
+        <div class="row text-center author-footer">
+            <?php
+            $github_url = '';
+            $weibo_url = '';
+            if (!isset($user->id)) {
+                $github_url = $systemPresenter->getKeyValue('github_url');
+                $weibo_url = $systemPresenter->getKeyValue('weibo_url');
+            }
+            ?>
+            @if ($github_url != "")
+                <span class="icon-github" style="padding-left:20px;">
+                    <a href='{{ $github_url }}' target="_blank">GitHub</a>
+                </span>
+            @endif
+            @if ($weibo_url != "")
+                <span class="icon-sina-weibo" style="padding-left:20px;margin-left:10px;">
+                    <a href='{{ $weibo_url }}' target="_blank">Weibo</a>
+                </span>
+            @endif
+        </div>
+    </div>
+</div>

+ 0 - 17
resources/views/default/home.blade.php

@@ -15,23 +15,6 @@
                 <h1 class="to-animate fadeInUp animated">
                     {{ $systemPresenter->getKeyValue('motto') }}
                 </h1>
-                <div class="to-animate fadeInUp animated">
-                    <?php
-                    $github_url = $systemPresenter->getKeyValue('github_url');
-                    $weibo_url = $systemPresenter->getKeyValue('weibo_url');
-                    ?>
-                    @if ($github_url != "")
-                        <span class="icon-github" style="padding-left:20px;">
-                            <a href='{{ $github_url }}' target="_blank">GitHub</a>
-                        </span>
-                    @endif
-                    @if ($weibo_url != "")
-                        <span class="icon-sina-weibo" style="padding-left:20px;margin-left:10px;">
-                            <a href='{{ $weibo_url }}' target="_blank">Weibo</a>
-                        </span>
-                    @endif
-
-                </div>
             </div>
         </div>
     </div>

+ 2 - 0
resources/views/layouts/app.blade.php

@@ -63,6 +63,8 @@
                 @yield('content')
             </div>
             <div class='col-md-4'>
+                @include('default.author')
+
                 @include('default.search')
 
                 @include('default.tag')