Commits

Ian Lewis committed 8d40198

Updated the top page and did css adjustments for mobile

  • Participants
  • Parent commits 8ca6af9
  • Branches bootstrap

Comments (0)

Files changed (10)

homepage/core/context_processors.py

+#:coding=utf-8:
+
+from django.conf import settings
+
+def debug(request):
+    return {
+        'debug': settings.DEBUG,
+    }

homepage/core/views.py

 #:coding=utf8:
 
 from django.http import HttpResponseRedirect 
-from django.views.generic.list_detail import object_list,object_detail
+#from django.views.generic.list_detail import object_list, object_detail
 from django.views.decorators.http import require_http_methods
 from django.core.urlresolvers import reverse
+from django.shortcuts import render
 from django.db.models import Q
 
 from tagging.views import tagged_object_list
 
 @require_http_methods(['GET', 'HEAD'])
 def main_page(request):
-    # Get latest English and Japanese post.
-    try:
-        en_post = Post.objects.published().filter(locale="en").latest("pub_date")
-    except Post.DoesNotExist:
-        en_post = None
-    try:
-        jp_post = Post.objects.published().filter(locale="jp").latest("pub_date")
-    except Post.DoesNotExist:
-        jp_post = None
+    en_posts = Post.objects.published().filter(locale="en").order_by("-pub_date")
+    jp_posts = Post.objects.published().filter(locale="jp").order_by("-pub_date")
     
-    try:
-        latest_tweet = Item.objects.published()\
-                           .filter(feed__domain="twitter.com")\
-                           .latest('date')
-    except Item.DoesNotExist:
-        latest_tweet = None
-  
-    return object_list(request, 
-        queryset = Item.objects.published().exclude(feed__domain="twitter.com"), 
-        template_name = "lifestream/main.html",
-        extra_context = {
-            'latest_tweet': latest_tweet,
-            "jp_post": jp_post,
-            "en_post": en_post,
-            'rss_feed_url': reverse('lifestream_recent_feed'),
-        }
-    )
+    return render(request, "index.html", {
+        #'latest_tweet': latest_tweet,
+        "jp_posts": jp_posts,
+        "en_posts": en_posts,
+    })
 
-@require_http_methods(['GET', 'HEAD'])
-def domain_page(request, domain):
-    return object_list(
-        request,
-        queryset=Item.objects.published().filter(feed__domain=domain),
-    )
+#@require_http_methods(['GET', 'HEAD'])
+#def tag_page(request, tag):
+#    return tagged_object_list(
+#        request,
+#        queryset_or_model=Item.objects.published(),
+#        tag=tag,
+#        extra_context={
+#            "rss_feed_url": reverse("lifestream_tag_feeds", kwargs={"tag": tag}),
+#        }
+#    )
 
-@require_http_methods(['GET', 'HEAD', 'POST'])
-def item_page(request, item_id):
-    return object_detail(
-        request,
-        queryset=Item.objects.published(),
-        object_id=item_id,    
-    )
-
-@require_http_methods(['GET', 'HEAD'])
-def tag_page(request, tag):
-    return tagged_object_list(
-        request,
-        queryset_or_model=Item.objects.published(),
-        tag=tag,
-        extra_context={
-            "rss_feed_url": reverse("lifestream_tag_feeds", kwargs={"tag": tag}),
-        }
-    )
-
-@require_http_methods(['GET', 'HEAD'])
-def search(request):
-    # Get unique keywords
-    raw_keywords = request.GET.get("q") or ""
-    domain = request.GET.get("domain")
-    keywords = list(set((raw_keywords).split()))
-    if keywords: 
-        queryset = Item.objects.published()
-        for keyword in keywords:
-            queryset = queryset.filter(Q(title__icontains=keyword) | Q(clean_content__icontains=keyword))
-        if domain:
-            queryset = queryset.filter(feed__domain=domain)
-    else:
-        #queryset = Item.objects.none()
-        return HttpResponseRedirect(reverse('main_page'))
-
-    return object_list(
-        request,
-        template_name='lifestream/item_search.html',
-        queryset=queryset,
-        extra_context={
-            'keywords': raw_keywords,
-        },
-    )
+#@require_http_methods(['GET', 'HEAD'])
+#def search(request):
+#    # Get unique keywords
+#    raw_keywords = request.GET.get("q") or ""
+#    domain = request.GET.get("domain")
+#    keywords = list(set((raw_keywords).split()))
+#    if keywords: 
+#        queryset = Item.objects.published()
+#        for keyword in keywords:
+#            queryset = queryset.filter(Q(title__icontains=keyword) | Q(clean_content__icontains=keyword))
+#        if domain:
+#            queryset = queryset.filter(feed__domain=domain)
+#    else:
+#        #queryset = Item.objects.none()
+#        return HttpResponseRedirect(reverse('main_page'))
+#
+#    return object_list(
+#        request,
+#        template_name='lifestream/item_search.html',
+#        queryset=queryset,
+#        extra_context={
+#            'keywords': raw_keywords,
+#        },
+#    )

homepage/settings.py

 STATICFILES_FINDERS = (
     "django.contrib.staticfiles.finders.FileSystemFinder",
     "django.contrib.staticfiles.finders.AppDirectoriesFinder",
-    "core.finders.AppMediaDirectoriesFinder",
+    "homepage.core.finders.AppMediaDirectoriesFinder",
 )
 
 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
 TEMPLATE_CONTEXT_PROCESSORS = (
     "django.contrib.auth.context_processors.auth",
     'django.contrib.messages.context_processors.messages',
-    "django.core.context_processors.debug",
     "django.core.context_processors.i18n",
     "django.core.context_processors.media",
     "django.core.context_processors.static",
     "django.core.context_processors.request",
+    "homepage.core.context_processors.debug",
 )
 
 MIDDLEWARE_CLASSES = (
 
 urlpatterns += patterns('homepage.core.views',
     url(r'^$', 'main_page', name='main_page'), 
-    url(r'^items/tag/(?P<tag>.+)$', 'tag_page', name='tag_page'),
+    #url(r'^items/tag/(?P<tag>.+)$', 'tag_page', name='tag_page'),
 
-    url(r'^items/view/(?P<item_id>\d+)$', 'item_page', name='lifestream_item_page'),
-    url(r'^items/site/(?P<domain>.+)$', 'domain_page', name='lifestream_domain_page'),
+    #url(r'^items/view/(?P<item_id>\\d+)$', 'item_page', name='lifestream_item_page'),
+    #url(r'^items/site/(?P<domain>.+)$', 'domain_page', name='lifestream_domain_page'),
 
-    url(r'^items/search$', 'search', name='lifestream_item_search'),
+    #url(r'^items/search$', 'search', name='lifestream_item_search'),
 )
 
 class HomepageRecentItemsFeed(RecentItemsFeed):

static/css/style.css

 }
 
 .header .header-inner {
-    position: relative;
     margin: 0 auto;
     max-width: 800px;
 }
 .header .header-inner .profile-img {
-
+    display: inline;
 }
 
 .header .title {
 }
 
 .header .about {
+    display: inline;
+    width: 100px;
     /* background: #FFFFCC; */
-    position: absolute;
-    top: 0;
-    left: 100px;
     color: #CCCCCC;
     /* width: 450px; */
     margin-left: 20px;
-    font-size: 1.5em;
+    font-size: 1.3em;
 }
 
 .header .search-box {
 
 /* =========== Lifestream ============== */
 
-.content #lifestream {
+.content #index {
     margin-top: 1em;
 }
 
-.content #lifestream .blog-hero {
-    height: 160px;
+.content #index .blog-hero {
+    margin-bottom: 20px;
 }
+.content #index .blog-hero a {
+    display: block;
+    padding: 10px 19px;
+
+    text-align: center;
+    line-height: 20px;
+    font-size: 1.5em;
+    font-weight: bold;
+    height: 200px;
+
+    border: 1px solid #ddd;
+    -webkit-border-radius: 4px;
+       -moz-border-radius: 4px;
+            border-radius: 4px;
+    -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075);
+       -moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075);
+            box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075);
+}
+.content #index .blog-hero .blog-hero-flag {
+    height: 170px;
+}
+.content #index .blog-hero .blog-hero-inner {
+    /* 
+      160 (blog-hero height)
+    - 8 * 2 (blog-hero padding)
+    - 10 * 2 (blog-hero-inner padding)
+    - 1 * 2 (blog-hero border)
+    */
+    height: 130px; 
+    background-color: #f5f5f5;
+}
+
+.content #index .blog-hero:hover {
+  border-color: #0088cc;
+  -webkit-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);
+     -moz-box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);
+          box-shadow: 0 1px 4px rgba(0, 105, 214, 0.25);
+}
+
+.content #index .blog-hero .blog-link-title {
+    font-size: 1.5em;
+    font-weight: bold;
+}

static/img/japan_flag.png

Added
New image

static/img/usa_flag.png

Added
New image

templates/base.html

     {% endif %}
     <meta name="keywords" content="{% block keywords %}Ian Lewis, イアン・ルイス, Tokyo, 東京, Japan,日本, Django, Python, BeProud, ビープラウド{% endblock %}"> 
     <meta name="description" content="{% block description %}Ian Lewis is a web developer living in Tokyo Japan. His current interests are in Django, python, cloud computing, alternative databases, and rapid web application development.{% endblock %}">
+    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
     {% block extra_meta %}{% endblock %}
     {% block rss %}{% endblock %}
     {% block javascript %}{% endblock %}
       <div class="header">
         {% block header %}
         <div class="header-inner container">
-          <div class="profile-img">
-            <a href="{% url main_page %}"><img src="{{ STATIC_URL }}img/profile.jpg" alt="Ian Lewis" height="90px" width="90px"></a>
-          </div>
-          <div class="about">
-              <span class="title"><a href="{% url main_page %}">Ian Lewis</a></span> is a web developer living in Tokyo Japan. His current interests are in <a href="http://www.djangoproject.com/">Django</a>, <a href="http://www.python.org/">python</a>, <a href="http://blip.tv/file/1949416">alternative databases</a> and <a href="http://www.google.com/search?q=rapid+web+application+development">rapid web application development</a>. <a class="profile-link" href="/en/about/">About Me...</a>
+            <table class="about">
+              <tbody>
+                <tr>
+                  <td style="width:90px;padding-right:20px;"><a href="{% url main_page %}"><img src="{{ STATIC_URL }}img/profile.jpg" alt="Ian Lewis" height="90px" width="90px"></a></td>
+                  <td>
+                    <span class="title"><a href="{% url main_page %}">Ian Lewis</a></span> is a web developer living in Tokyo Japan. His current interests are in <a href="http://www.djangoproject.com/">Django</a>, <a href="http://www.python.org/">python</a>, <a href="http://blip.tv/file/1949416">alternative databases</a> and <a href="http://www.google.com/search?q=rapid+web+application+development">rapid web application development</a>. <a class="profile-link" href="/en/about/">About Me...</a>
+                  </td>
+                </tr>
+              </tbody>
+            </table>
           </div>
         </div>
         {# TODO: search etc. #}

templates/index.html

+{% extends "base.html" %}
+{% load utility_tags lifestream_tags pagination_tags tagging_tags blog_tags %}
+
+{% block content %}
+<div id="index">
+  <div class="blog-links">
+    <div class="row-fluid">
+      <div class="blog-hero span6">
+        <a href="{% url blog_page "en" %}">
+          <div class="blog-hero-flag">
+            <img src="{{ STATIC_URL }}img/usa_flag.png" /><br />
+          </div>
+          <div class="blog-hero-text">English Blog</div>
+        </a>
+      </div>
+
+      <div class="blog-hero span6">
+        <a href="{% url blog_page "jp" %}">
+          <div class="blog-hero-flag">
+            <img src="{{ STATIC_URL }}img/japan_flag.png" style="border: 1px solid #DDD;"/><br />
+          </div>
+          <div class="blog-hero-text">日本語ブログ</div>
+        </a>
+      </div>
+    </div>
+  </div>
+
+  <div class="blog-two-column row-fluid">
+    <div class="span6">
+      {% for post in en_posts %}
+      {{ post.title }}
+      {% endfor %}
+    </div>
+    <div class="span6">
+      {% for post in jp_posts %}
+      {{ post.title }}
+      {% endfor %}
+    </div>
+  </div>
+</div>
+{% endblock %}

templates/lifestream/main.html

 <div class="blog-links">
   {% if en_post %}
   <div class="row-fluid">
-    <div class="blog-hero well span6"
-         onclick="window.location='{% url blog_page "en" %}';"
-         onmouseover="$(this).addClass('over');"
-         onmouseout="$(this).removeClass('over');"
-    >
-      {% if en_post %}
-        <div class="blog-title">English Blog</div>
-        <div class="blog-link-title">{{ en_post.title }}</div>
-        <div class="blog-link-content">{{ en_post|to_html|striptags|truncate_chars:80|safe }}</div>
-      {% endif %}
-      <div class="more">Read More</div>
+    <div class="blog-hero span6" onclick="window.location='{% url blog_page "en" %}';">
+        {% if en_post %}
+          <div class="blog-title">English Blog</div>
+          <div class="blog-link-title">{{ en_post.title }}</div>
+          <div class="blog-link-content">{{ en_post|to_html|striptags|truncate_chars:80|safe }}</div>
+        {% endif %}
+        <div class="more">Read More</div>
     </div>
     {% endif %}
 
     {% if jp_post %}
-    <div class="blog-hero well span6"
-         onclick="window.location='{% url blog_page "jp" %}';"
-         onmouseover="$(this).addClass('over');"
-         onmouseout="$(this).removeClass('over');"
-    >
-      {% if jp_post %}
-        <div class="blog-title">日本語ブログ</div>
-        <div class="blog-link-title">{{ jp_post.title }}</div>
-        <div class="blog-link-content">{{ jp_post|to_html|striptags|truncate_chars:60|safe }}</div>
-      {% endif %}
-      <div class="more">もっと見る</div>
+    <div class="blog-hero span6" onclick="window.location='{% url blog_page "jp" %}';">
+        {% if jp_post %}
+          <div class="blog-title">日本語ブログ</div>
+          <div class="blog-link-title">{{ jp_post.title }}</div>
+          <div class="blog-link-content">{{ jp_post|to_html|striptags|truncate_chars:60|safe }}</div>
+        {% endif %}
+        <div class="more">もっと見る</div>
     </div>
   </div>
   {% endif %}