From 318d65bf3ad277a180524269931a9d73ec2d6f85 Mon Sep 17 00:00:00 2001
From: Jan Broer <janeczku@yahoo.de>
Date: Sun, 3 Apr 2016 23:33:29 +0200
Subject: [PATCH] Small UI fixes

* Smart truncate long titles in overview pages
* Fix responsive grid in overview
* Update favicon
---
 cps/static/css/style.css    |   6 +++---
 cps/static/favicon.ico      | Bin 519 -> 1150 bytes
 cps/templates/detail.html   |   2 +-
 cps/templates/discover.html |   2 +-
 cps/templates/index.html    |   4 ++--
 cps/templates/search.html   |   2 +-
 cps/templates/shelf.html    |   2 +-
 cps/web.py                  |   9 +++++++++
 8 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/cps/static/css/style.css b/cps/static/css/style.css
index 52e2f1e4..8a16b3f0 100644
--- a/cps/static/css/style.css
+++ b/cps/static/css/style.css
@@ -8,7 +8,7 @@ a{color: #45b29d}a:hover{color: #444;}
 .container-fluid img{display:block;max-width:100%;height:auto}
 .container-fluid .discover{margin-bottom:50px}
 .container-fluid .new-books{border-top:1px solid #ccc}.container-fluid .new-books h2{margin:50px 0 0 0}
-.container-fluid .book{margin-top:20px}.container-fluid .book .cover{height:225px;position:relative}.container-fluid .book .cover img{border:3px solid #fff;border-radius:5px;box-sizeing:border-box;height:100%;bottom:0;position:absolute;-webkit-box-shadow: 0 5px 8px -6px #777;-moz-box-shadow: 0 5px 8px -6px #777;box-shadow: 0 5px 8px -6px #777;}
+.container-fluid .book{margin-top:20px}.container-fluid .book .cover{height:225px;position:relative}.container-fluid .book .cover img{border:1px solid #fff;/*border-radius:7px;*/box-sizeing:border-box;height:100%;bottom:0;position:absolute;-webkit-box-shadow: 0 5px 8px -6px #777;-moz-box-shadow: 0 5px 8px -6px #777;box-shadow: 0 5px 8px -6px #777;}
 .container-fluid .book .meta{margin-top:10px}.container-fluid .book .meta p{margin:0}
 .container-fluid .book .meta .title{font-weight:bold;font-size:15px;color:#444}
 .container-fluid .book .meta .author{font-size:12px;color:#999}
@@ -21,8 +21,8 @@ span.glyphicon.glyphicon-tags {padding-right: 5px;color: #999;vertical-align: te
 .book-meta {padding-bottom: 20px;}
 .book-meta .tags a {display: inline;}
 .container-fluid .single .cover img {
-    border: 3px solid #fff;
-    border-radius: 5px;
+    border: 1px solid #fff;
+    /*border-radius: 7px;*/
     box-sizeing: border-box;
     -webkit-box-shadow: 0 5px 8px -6px #777;
     -moz-box-shadow: 0 5px 8px -6px #777;
diff --git a/cps/static/favicon.ico b/cps/static/favicon.ico
index 75e6ecc39b4fda06ffe4e24ad60378142a72c005..4633936532a7a14771be94e26e47e8dad3a66921 100644
GIT binary patch
literal 1150
zcmZQzU<5(|0R|wcz>vYhz#zuJz@P!dKp~(AL>x#lFaYJy!T<mN8EAozUYzoO>ygs`
zdr!Cizj1#T&<f)1S++Cm|J+Tk{}*iW0n%<@_V%L{M47ScL_Jvj`5VjO>i3`N_`i62
z5S)+CElYQV{oit=m?*W_%$dL0^Z(iFi^<jx^6%x_>nYQJXCvAALGC|!W$yot2Xp@~
z-WKqG|Cvsb%v!N48XSK6PPhHvcC-u}7mK$A5^V-3{y=U30(iPyxYh6firq0NV#xC7
z?D<=~{_i|d3s-;X)>^PTuHD-P7em*B%-?&e6|DZqg-LMrp!9h9>H;_)Sv@v3C=G%1
zEZXM(f8kc&|MNC`{J-<~5YhTUW`f)e%0r;IxNvhNNqVul3A-2r!ykJFh9B|_3?Jt+
lFns=xia*pdFnq8FiUH+*_5;<O2dd|1VE8A`0E{071^@+k5)%Lb

literal 519
zcmV+i0{H!jP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV0005bNkl<ZIE~Gd
zyKWOv6h+sy$K!E`CCAutY(t0~A<-Z}P*@02@B#Fce1v}iYHC{e2E?nN0xX0SVNiG|
z<|W5Y;;}t5p1F5kmjWpQiKIvxcDr?!&OTd5NGUbPQ06$pe*sjekWq9rfUo9sUOnRO
zyVv{1vwn{^yCZfyo3E~WAiw~4@_mz=>zCQs>F*mKC%briLr&&TuvS@Rtyny01I?!6
z(5{qGf1EQX3^afchet@_kT8z8^Y#VpdW$d)=}&FKG@`Xs=lV*MG>r+A<bJP<EdyNX
zGxF!ZBLs0sbzzC~l^R!9nmqXMl5r?di6ZePm^x*{9<t?(`83_;-h0U@Q!q_)bS|{X
zXf&2t;97kZLBc>P%7r`{L919I(VDSTgo)x(<upw*hnIkbMr%#R%oxa60T2cr)x|QA
zPRSVs%6Su|Qx?q}drA?jIXY|bWj3NwEb;tjAH&S$8G2*3-6@Z^dN>&a6)6V3OKF;A
zBqOR;fv!Ddy><pCl*|%A!!)q9AR|PUcC|*Q`;=;_&SY*g3S8>e0zZ6-o5TzPhudeb
zaO>Pf_WT()mYY2M_L=r_10ki<XicCL1<N|LvVTeZKhJbj{Q@9!-=m<K%;o?9002ov
JPDHLkV1i#|=VAZ=

diff --git a/cps/templates/detail.html b/cps/templates/detail.html
index 316ab098..98ba03f7 100644
--- a/cps/templates/detail.html
+++ b/cps/templates/detail.html
@@ -9,7 +9,7 @@
         {% endif %}
       </div>
     </div>
-    <div class="col-lg-7 book-meta">
+    <div class="col-sm-9 col-lg-9 book-meta">
       <h2>{{entry.title}}</h2>
       <p class="author"><a href="{{url_for('author', name=entry.authors[0].name) }}">{{entry.authors[0].name}}</a>
       </p>
diff --git a/cps/templates/discover.html b/cps/templates/discover.html
index 792bd2a2..5480cedd 100644
--- a/cps/templates/discover.html
+++ b/cps/templates/discover.html
@@ -14,7 +14,7 @@
         {% endif %}
       </div>
       <div class="meta">
-        <p class="title">{{entry.title}}</p>
+        <p class="title">{{entry.title|shortentitle}}</p>
         <p class="author"><a href="{{url_for('author', name=entry.authors[0].name) }}">{{entry.authors[0].name}}</a></p>
         {% if entry.ratings.__len__() > 0 %}
         <div class="rating">
diff --git a/cps/templates/index.html b/cps/templates/index.html
index 5b061133..d7b0a022 100755
--- a/cps/templates/index.html
+++ b/cps/templates/index.html
@@ -15,7 +15,7 @@
         {% endif %}
       </div>
       <div class="meta">
-        <p class="title">{{entry.title}}</p>
+        <p class="title">{{entry.title|shortentitle}}</p>
         <p class="author"><a href="{{url_for('author', name=entry.authors[0].name) }}">{{entry.authors[0].name}}</a></p>
         {% if entry.ratings.__len__() > 0 %}
         <div class="rating">
@@ -50,7 +50,7 @@
         {% endif %}
       </div>
       <div class="meta">
-        <p class="title">{{entry.title}}</p>
+        <p class="title">{{entry.title|shortentitle}}</p>
         <p class="author"><a href="{{url_for('author', name=entry.authors[0].name) }}">{{entry.authors[0].name}}</a></p>
         {% if entry.ratings.__len__() > 0 %}
         <div class="rating">
diff --git a/cps/templates/search.html b/cps/templates/search.html
index fa9f5a23..dd32ab7e 100644
--- a/cps/templates/search.html
+++ b/cps/templates/search.html
@@ -21,7 +21,7 @@
         {% endif %}
       </div>
       <div class="meta">
-        <p class="title">{{entry.title}}</p>
+        <p class="title">{{entry.title|shortentitle}}</p>
         <p class="author"><a href="{{url_for('author', name=entry.authors[0].name) }}">{{entry.authors[0].name}}</a></p>
         {% if entry.ratings.__len__() > 0 %}
         <div class="rating">
diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html
index 4d89c472..9a06dddc 100644
--- a/cps/templates/shelf.html
+++ b/cps/templates/shelf.html
@@ -14,7 +14,7 @@
         {% endif %}
       </div>
       <div class="meta">
-        <p class="title">{{entry.title}}</p>
+        <p class="title">{{entry.title|shortentitle}}</p>
         <p class="author"><a href="{{url_for('author', name=entry.authors[0].name) }}">{{entry.authors[0].name}}</a></p>
         {% if entry.ratings.__len__() > 0 %}
         <div class="rating">
diff --git a/cps/web.py b/cps/web.py
index dc28f2b8..1b75f13c 100755
--- a/cps/web.py
+++ b/cps/web.py
@@ -4,6 +4,7 @@
 import mimetypes
 import logging
 import sys
+import textwrap
 mimetypes.add_type('application/xhtml+xml','.xhtml')
 from flask import Flask, render_template, session, request, Response, redirect, url_for, send_from_directory, make_response, g, flash, abort
 from cps import db, config, ub, helper
@@ -122,6 +123,14 @@ def url_for_other_page(page):
 
 app.jinja_env.globals['url_for_other_page'] = url_for_other_page
 
+## custom jinja filters
+@app.template_filter('shortentitle')
+def shortentitle_filter(s):
+    if len(s) > 60:
+        s = s.split(':', 1)[0]
+        if len(s) > 60:
+            s = textwrap.wrap(s, 60, break_long_words=False)[0]+' [...]'
+    return s
 
 def admin_required(f):
     """