Daniel Müllers 10 лет назад
Родитель
Сommit
6099335b5e
5 измененных файлов с 64 добавлено и 34 удалено
  1. 31 11
      app/routes.php
  2. 19 11
      app/views/film.blade.php
  3. 1 0
      app/views/hello.blade.php
  4. 7 4
      app/views/index.blade.php
  5. 6 8
      app/views/suggest.blade.php

+ 31 - 11
app/routes.php

@@ -21,7 +21,7 @@ Route::get('/', function()
 	$topfilm = DB::table(DB::raw('film_films'))
 	->select(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes, 
 		COUNT(case when film_votes.stimme IS FALSE then 1 end) as downvotes, 
-		COUNT(case when film_votes.stimme IS TRUE then 1 end) - COUNT(case when film_votes.stimme IS FALSE then 1 end) as vcount'))
+		COUNT(case when film_votes.stimme IS TRUE then 1 end) as vcount'))
 	->leftJoin('votes', 'votes.film', '=', 'films.id')
 	->whereNull('films.gesehen')
 	->where('films.id', "!=", is_object($nextfilm) ? $nextfilm->id : 0)
@@ -64,14 +64,15 @@ Route::get('film/{id}', array('as' => 'film', function($id) {
 
 	$votes = $film->votes()->count();
 	$vposi = $film->votes()->where('stimme', true)->count();
-	$pv = "";
+
+	$pv = array();
 	foreach($film->votes()->where('stimme', true)->get() as $v) {
-		$pv .= $v->voter->name . "<br> ";
+		$pv[] = $v->voter->name;
 	}
 
-	$nv = "";
+	$nv = array();
 	foreach($film->votes()->where('stimme', false)->get() as $v) {
-		$nv .= $v->voter->name . "<br> ";
+		$nv[] = $v->voter->name;
 	}
 
 	if(!is_null(Auth::user()) && $film->votes()->where('user', Auth::user()->id)->count() > 0) {
@@ -161,25 +162,44 @@ Route::get('logout', array('as' => 'logout', function() {
 	return Redirect::to('/');
 }));
 
-Route::get('vorgeschlagen', function() {
+Route::get('beliebt', function() {
 	
 	$filme = DB::table(DB::raw('film_films'))
 	->select(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes, 
 		COUNT(case when film_votes.stimme IS FALSE then 1 end) as downvotes, 
-		COUNT(case when film_votes.stimme IS TRUE then 1 end) - COUNT(case when film_votes.stimme IS FALSE then 1 end) as vcount'))
+		COUNT(case when film_votes.stimme IS TRUE then 1 end) as vcount'))
 	->leftJoin('votes', 'votes.film', '=', 'films.id')
 	->whereNull('films.gesehen')
 	->groupBy('id')
 	->orderBy('vcount', 'DESC')->orderBy('vorgeschlagen', 'ASC')
-	->paginate();
+	->paginate(25);
 
 	return View::make('suggest')
-		->with('filme', $filme);
+		->with('filme', $filme)
+		->with('titel', 'Vorschl&auml;ge nach Wertung');
 
-})->where(array('field' => '[a-z]+', 'order' => 'asc|desc'));
+});
+
+Route::get('vorgeschlagen', function() {
+
+	$filme = DB::table(DB::raw('film_films'))
+		->select(DB::raw('film_films.*, COUNT(case when film_votes.stimme IS TRUE then 1 end) as upvotes,
+		COUNT(case when film_votes.stimme IS FALSE then 1 end) as downvotes,
+		COUNT(case when film_votes.stimme IS TRUE then 1 end) as vcount'))
+		->leftJoin('votes', 'votes.film', '=', 'films.id')
+		->whereNull('films.gesehen')
+		->groupBy('id')
+		->orderBy('vorgeschlagen', 'DESC')
+		->paginate(25);
+
+	return View::make('suggest')
+		->with('filme', $filme)
+		->with('titel', 'Vorschl&auml;ge nach Datum');
+
+});
 
 Route::get('gesehen/{field?}/{order?}', function($field = "gesehen", $order = "desc") {
-	$filme = Film::whereNotNull('gesehen')->orderBy($field, $order)->paginate();
+	$filme = Film::whereNotNull('gesehen')->orderBy($field, $order)->paginate(25);
 
 	return View::make('seen')
 		->with('filme', $filme);

+ 19 - 11
app/views/film.blade.php

@@ -103,17 +103,25 @@
 @if($votes > 0)
 <h2>Abstimmung</h2>
 <p>Insgesamt haben <b>{{$votes}}</b> Personen abgestimmt. <b>{{$vposi}}</b> davon waren <i>daf&uuml;r</i>. @if($uvote[0])
-	Du hast <i>{{ $uvote[1] ? "daf&uuml;r" : "dagegen"}}</i> gestimmt.
+	Du hast <i>{{ $uvote[1] ? "daf&uuml;r" : "nicht daf&uuml;r"}}</i> gestimmt.
 @endif
+</p>
+<dl class="dl-horizontal">
+	<dt>Daf&uuml;r</dt>
+	<dd>
+		@foreach($pv as $v)
+			<span class="badge">{{$v}}</span>
+		@endforeach
+	</dd>
+	<dt>Nicht daf&uuml;r</dt>
+	<dd>
+		@foreach($nv as $v)
+			<span class="badge">{{$v}}</span>
+		@endforeach
+	</dd>
+</dl>
+
 
-<div class="progress">
-  <div class="progress-bar progress-bar-success tooltip-enable" style="width: {{ $vposi / $votes * 100}}%" data-toggle="tooltip" data-title="{{$pv}}">
-    <span class="sr-only">{{$vposi}} von {{$votes}} (daf&uuml;r)</span>
-  </div>
-  <div class="progress-bar progress-bar-danger tooltip-enable" style="width: {{ ($votes - $vposi) / $votes * 100}}%" data-toggle="tooltip" data-title="{{$nv}}">
-    <span class="sr-only">{{ $votes - $vposi}} von {{ $votes }} (dagegen)</span>
-  </div>
-</div>
 @endif
 @if(is_null($film->gesehen) && !is_null(Auth::user()))
 <div class="container" style="text-align: center">
@@ -121,8 +129,8 @@
 		<a class="btn btn-lg btn-success <?php echo $uvote[0] && $uvote[1] ? "disabled" : ""; ?>" href="{{ url('vote', array('yes', Auth::user()->id, $film->id)) }}">
 			<span class="glyphicon glyphicon-thumbs-up"></span> Daf&uuml;r
 		</a>
-		<a class="btn btn-lg btn-danger <?php echo $uvote[0] && !$uvote[1] ? "disabled" : ""; ?>"  href="{{ url('vote', array('no', Auth::user()->id, $film->id)) }}">
-			<span class="glyphicon glyphicon-thumbs-down"></span> Dagegen
+		<a class="btn btn-lg btn-warning <?php echo $uvote[0] && !$uvote[1] ? "disabled" : ""; ?>"  href="{{ url('vote', array('no', Auth::user()->id, $film->id)) }}">
+			<span class="glyphicon glyphicon-hand-right"></span> Nicht daf&uuml;r
 		</a>
 	</div>
 </div>

+ 1 - 0
app/views/hello.blade.php

@@ -21,6 +21,7 @@
 			</div>     
 		    <div class="navbar-collapse collapse">
 				<ul class="nav navbar-nav">
+					<li>{{ HTML::link('beliebt', 'Beliebt') }}</li>
 					<li>{{ HTML::link('vorgeschlagen', 'Vorgeschlagen') }}</li>
 					<li>{{ HTML::link('gesehen', 'Gesehen') }}</li>
 					<li>{{ HTML::link('neu', 'Film vorschlagen')}}

+ 7 - 4
app/views/index.blade.php

@@ -8,8 +8,8 @@
 			<div class="panel-body">
 				<img src="{{$image}}" class="pull-left thumbnail" style="max-height: 100px; margin-right: 15px;">
 				<h4>{{$topfilm->name}}</h4>
-				<p><span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;{{$topfilm->upvotes}} 
-					<span class="glyphicon glyphicon-thumbs-down"></span>&nbsp;{{$topfilm->downvotes}}</p>
+				<p><span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;{{$topfilm->upvotes}}
+					<span class="glyphicon glyphicon-sort-by-attributes"></span>&nbsp;{{$topfilm->downvotes + $topfilm->upvotes}}</p>
 				@if(!is_null(Auth::user()) && Auth::user()->admin)
 					<a href='{{ url('view-next/' . $topfilm->id) }}' class='btn btn-success btn-xs'>Als n&auml;chstes sehen</a>
 				@endif
@@ -17,6 +17,7 @@
 
 			<div class="list-group">
 				{{ link_to_route('film', "Filmdetails", array($topfilm->id), array('class' => 'list-group-item'))}}
+				{{ link_to('beliebt', 'Mehr beliebte Filme', array('class' => 'list-group-item')); }}
 			</div>
 		</div>
 	</div>
@@ -50,7 +51,8 @@
 			<div class="list-group">
 				@foreach ($vorgeschlagen as $film)
 					<a href="{{ route('film', array($film->id)); }}" class="list-group-item">{{$film->name}} <small>({{ $film->besitzer->name }})</small></a>
-				@endforeach	
+				@endforeach
+					{{ link_to('vorgeschlagen', 'Mehr...', array('class' => 'list-group-item')); }}
 			</div>
 		</div>
 	</div>
@@ -61,7 +63,8 @@
 			<div class="list-group">
 				@foreach ($gesehen as $film)
 					{{ link_to_route('film', $film->name, array($film->id), array('class' => 'list-group-item'))}}
-				@endforeach		
+				@endforeach
+					{{ link_to('gesehen', 'Mehr...', array('class' => 'list-group-item')); }}
 			</div>
 		</div>
 	</div>

+ 6 - 8
app/views/suggest.blade.php

@@ -1,7 +1,7 @@
 @extends('hello')
 
 @section('content')
-<div class="page-header"><h1>Vorschläge</h1></div>
+<div class="page-header"><h1>{{$titel}}</h1></div>
 
 {{ $filme->links() }}
 
@@ -27,18 +27,16 @@
 				$vp = $film->upvotes; 
 				$np = $film->downvotes;
 				?>
-			<span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;{{ $vp }}, 
-			<span class="glyphicon glyphicon-thumbs-down"></span>&nbsp;{{ $np }}
+			<span class="glyphicon glyphicon-sort-by-attributes"></span>&nbsp;{{ $vp + $np }}
 		</td>
 		<td>
-			@if(($vp - $np) > 0) 		<span class="label label-success">+{{$vp - $np}}</span>
-			@elseif(($vp - $np) < 0)	<span class="label label-danger">{{$vp - $np}}</span>
-			@else 						<span class="label label-warning">{{$vp - $np}}</span>
+			@if(($vp) > 0) 		<span class="label label-default">+{{$vp}}</span>
+			@else 						<span class="label label-default">0</span>
 			@endif
 			@if($stimme == 1)
 			&nbsp;<span class="label label-success tooltip-enable" data-toggle="tooltip" title="Daf&uuml;r gestimmt."><span class="glyphicon glyphicon-thumbs-up"></span></span>
 			@elseif($stimme == 0)
-			&nbsp;<span class="label label-danger tooltip-enable"  data-toggle="tooltip" title="Dagegen gestimmt."><span class="glyphicon glyphicon-thumbs-down"></span></span>
+			&nbsp;<span class="label label-warning tooltip-enable"  data-toggle="tooltip" title="Nicht daf&uuml;r gestimmt."><span class="glyphicon glyphicon-hand-right"></span></span>
 			@endif
 		</td>
 		<td>{{ \Carbon\Carbon::parse($film->vorgeschlagen)->format('d.m.Y')}}</td>
@@ -52,7 +50,7 @@
 @stop
 
 @section('title')
-Vorschläge ~
+{{$titel}} ~
 @stop
 
 @section('script')