Home site templates and basic view.
authorPawel Solyga <Pawel.Solyga@gmail.com>
Tue, 19 Aug 2008 17:57:58 +0000
changeset 79 58001ec7720c
parent 78 206e6eeed6c4
child 80 55542eddada5
Home site templates and basic view. Patch by: Pawel Solyga Review by: Todd Larsen Review issue: 385 Review URL: http://codereviews.googleopensourceprograms.com/385
AUTHORS
app/soc/content/css/soc.css
app/soc/content/js/blog.js
app/soc/templates/soc/base.html
app/soc/templates/soc/site/home.html
app/soc/views/site/__init__.py
app/soc/views/site/home.py
app/urls.py
--- a/AUTHORS	Tue Aug 19 17:52:13 2008 +0000
+++ b/AUTHORS	Tue Aug 19 17:57:58 2008 +0000
@@ -5,4 +5,4 @@
 
 "Todd Larsen" <tlarsen@google.com>
 "Sverre Rabbelier" <sverre@rabbelier.nl>
-
+"Pawel Solyga" <pawel.solyga@gmail.com>
--- a/app/soc/content/css/soc.css	Tue Aug 19 17:52:13 2008 +0000
+++ b/app/soc/content/css/soc.css	Tue Aug 19 17:57:58 2008 +0000
@@ -13,24 +13,296 @@
 See the License for the specific language governing permissions and
 limitations under the License.
  */
+ 
+/* ---------------------------- */ 
+/* STANDARD HTML TAG DEFINITION */ 
+/* ---------------------------- */ 
 
 body {
-  font-family: Verdana, Helvetica, sans-serif;
-  background-color: #DDDDDD;
+  background-color: white;
+  color: black;
+  font-family: Arial, sans-serif;
+  font-size: small;
+  margin: 8px;
+  margin-top: 3px;
+}
+
+img {
+  border: 0;
+}
+
+h1 {
+  font-size: x-large;
+  margin-top: 0px;
+}
+
+h2 {
+  font-size: large;
+}
+
+h3 {
+  font-size: medium;
+}
+
+h4 {
+  font-size: small;
+}
+
+form {
+  margin: 0;
+  padding: 0;
+}
+
+li {
+  margin-bottom: 0.25em;
+}
+
+pre, code {
+  color: #007000;
+  font-family: "bogus font here", monospace;
+  font-size: 100%;
+}
+
+pre {
+  border: 1px solid silver;
+  background-color: #f5f5f5;
+  padding: 0.5em;
+  overflow: auto;
+  margin: 2em;
+}
+
+pre ins {
+  color: #cc0000;
+  font-weight: bold;
+  text-decoration: none;
+}
+
+/* LINKS DEFINITION  */ 
+
+a:link {
+  color: #0000cc;
 }
 
-td.formfieldrequired {
- font-style: italic;
+a:active {
+  color: #cc0000;
+}
+
+a:visited {
+  color: #551a8b;
+}
+
+a.selected, .selected a, .selected {
+  color: black;
+  font-weight: bold;
+  text-decoration: none;
+}
+
+a.selected:visited, .selected a:visited {
+  color: black;
+}
+
+/* TABLE DEFINITION */
+
+table {
+  border-collapse: collapse;
+}
+
+th, td {
+  padding: 0;
+  vertical-align: top;
+  text-align: left;
+}
+
+        /* FORM FIELDS DEFINITION */ 
+
+        td.formfieldrequired {
+         font-style: italic;
+        }
+
+        td.formfieldhelptext {
+         font-style: italic;
+        }
+
+        td.formfielderror {
+         color: #FF0000;
+        }
+
+        td.formfieldheading {
+         font-weight: bold;
+        }
+
+
+/* ---------------------------- */ 
+/* PAGE ELEMENTS DEFINITION */ 
+/* ---------------------------- */
+
+#login {
+  text-align: right;
+}
+
+#header {
+  height: 50px;
+  margin-bottom: 11px;
+  position: relative;
+}
+
+#logo {
+  padding-right: 18px;
+  position: absolute;
+  left: 0;
+  top: -5px;
 }
 
-td.formfieldhelptext {
- font-style: italic;
+        #logo img {
+          width: 143px;
+          height: 59px;
+        }
+
+#title {
+  border-top: 1px solid #3366cc;
+  background-color: #e5ecf9;
+  font-size: large;
+  font-weight: bold;
+  margin: 0;
+  padding: 0;
+  padding-top: 1px;
+  padding-bottom: 1px;
+  margin-top: 5px;
+  margin-left: 200px;
+  padding-left: 3px;
+}
+
+#badge {
+  clear: both;
+  margin-top: 3.5em;
+  margin-bottom: 1em;
+  height: 53px;
+  font-style: italic;
+}
+
+#body {
+  border-left: 1px dotted silver;
+  margin-left: 200px;
+  margin-right: 25px;
+  padding-left: 18px;
+  padding-bottom: 25px;
+}
+
+#footer {
+  clear: both;
+  text-align: center;
+  margin-top: 3.5em;
+  margin-bottom: 1em;
+  background-image: url("http://www.google.com/images/art.gif");
+  height: 53px;
+  background-repeat: no-repeat;
+  background-position: left center;
+}
+
+        #footer .text {
+          padding-top: 20px;
+        }
+
+/* SIDE BAR MENU DEFINITION */
+
+#side {
+  width: 200px;
+  margin-bottom: 3em;
+  float: left;
+}
+
+#menu ul {
+  margin: 0;
+  padding: 0;
+  list-style-type: none;
+  margin-bottom: 1em;
+  font-size: 95%;
+}
+
+#menu ul ul {
+  margin-left: 10px;
+  margin-bottom: 0;
+}
+
+#menu li {
+  margin-top: 4px;
 }
 
-td.formfielderror {
- color: #FF0000;
+#menu h4 {
+  margin: 0;
+  padding: 0;
+  margin-bottom: 1em;
+}
+
+/* ---------------------------- */ 
+/* SEARCH FIELD DEFINITION */ 
+/* ---------------------------- */
+
+#search {
+  margin-top: 2em;
+}
+
+        #search .header {
+          font-weight: bold;
+          font-size: 90%;
+          margin-bottom: 1px;
+        }
+
+        #search .button {
+          margin-top: 1px;
+        }
+
+        #search .input input {
+          width: 125px;
+        }
+
+/* ---------------------------- */ 
+/* BLOG FEED DEFINITION */ 
+/* ---------------------------- */
+
+.blog {
+  border: 10px solid #e5ecf9;
+  border-top: 1px solid #3366cc;
 }
 
-td.formfieldheading {
- font-weight: bold;
+.blog h2 {
+  margin-top: 0.1em;
+  background-color: #e5ecf9;
+}
+
+.blog h2 a, .blog h2 a:visited {
+  text-decoration: none;
+  color: black;
+}
+
+.blog .entry {
+  margin-bottom: 1em;
+}
+
+.blog .title {
+   font-size: medium;
 }
+
+.blog .author {
+  color: gray;
+  margin-bottom: 0.5em;
+}
+
+.blog .snippet {
+  background-color: white;
+}
+
+/* ---------------------------- */ 
+/* CUSTOM CLASSES DEFINITION */ 
+/* ---------------------------- */
+
+.todo {
+  color: #cc0000;
+  font-size: 80%;
+}
+
+.newmark {
+  color: red;
+  font-size: 80%;
+  vertical-align: top;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/content/js/blog.js	Tue Aug 19 17:57:58 2008 +0000
@@ -0,0 +1,76 @@
+/* Copyright 2008 the Melange authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function BlogPreview(container) {
+  this.container_ = container;
+}
+
+BlogPreview.prototype.show = function(url, title, title_link) {
+  var feed = new google.feeds.Feed(url);
+  var preview = this;
+  feed.load(function(result) {
+    preview.render_(result, title, title_link);
+  });
+}
+
+BlogPreview.prototype.render_ = function(result, title, title_link) {
+  if (!result.feed || !result.feed.entries) return;
+  while (this.container_.firstChild) {
+    this.container_.removeChild(this.container_.firstChild);
+  }
+
+  var blog = this.createDiv_(this.container_, "blog");
+  var header = this.createElement_("h2", blog, "");
+  if (!title) {
+    title = result.feed.title;
+  }
+  if (!title_link) {
+    title_link = result.feed.link;
+  }
+  this.createLink_(header, title_link, title);
+
+  for (var i = 0; i < result.feed.entries.length; i++) {
+    var entry = result.feed.entries[i];
+    var div = this.createDiv_(blog, "entry");
+    var linkDiv = this.createDiv_(div, "title");
+    this.createLink_(linkDiv, entry.link, entry.title);
+    if (entry.author) {
+      this.createDiv_(div, "author", "Posted by " + entry.author);
+    }
+    this.createDiv_(div, "snippet", entry.contentSnippet);
+  }
+}
+
+BlogPreview.prototype.createDiv_ = function(parent, className, opt_text) {
+  return this.createElement_("div", parent, className, opt_text);
+}
+
+BlogPreview.prototype.createLink_ = function(parent, href, text) {
+  var link = this.createElement_("a", parent, "", text);
+  link.href = href;
+  return link;
+}
+
+BlogPreview.prototype.createElement_ = function(tagName, parent, className,
+                                                opt_text) {
+  var div = document.createElement(tagName);
+  div.className = className;
+  parent.appendChild(div);
+  if (opt_text) {
+    div.appendChild(document.createTextNode(opt_text));
+  }
+  return div;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/base.html	Tue Aug 19 17:57:58 2008 +0000
@@ -0,0 +1,176 @@
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+ <head>
+  <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
+	{% block stylesheet %}
+  <link rel="stylesheet" href="/soc/content/css/soc.css" type="text/css"/>
+	{% endblock %}
+  <title>{% block page_title %}Google Open Source Programs{% endblock %}</title>
+	{% block scripts %}{% endblock %}
+
+ </head>
+
+ <body>
+
+  <div id="login">
+	{% block login_links %}
+   <a href="http://code.google.com/p/soc/issues/list">Report bugs</a> | 
+   <a href="/">Sign in</a>
+	{% endblock %}
+  </div>
+
+  <div id="header">
+   <div id="logo">
+	{% block logo %}
+<a href="/"><img src="/soc/content/images/gospo-logo.gif" alt="Google Open Source Programs"/></a>
+   <span title=" TODO: logo updated in site sponsor interface " class="popup">
+<small>*</small>
+   </span>
+	{% endblock %}
+   </div>
+
+   <div id="title">
+	{% block header_title %}Google Open Source Programs{% endblock %}
+   </div>
+  </div>
+
+  <div id="side" dir="ltr">
+   <div id="menu">
+{% block sidebar_menu %}	
+    <ul>
+     <li>
+<a class="selected" href="/">Google Open Source Programs</a>
+      <ul>
+       <li>
+<a href="/user/linkname/profile">User (Sign In)</a>
+   <span title=" No Profile or Roles sidebar menu items until user signs in " class="popup">
+<small>*</small>
+   </span>
+
+       </li>
+      </ul>
+      <ul>
+       <li>
+<a href="/program/gsoc2009/home">Google Summer of Code</a>
+        <ul>
+         <li>
+<a href="/program/gsoc2009/community">Community</a>
+         </li>
+         <li>
+<a href="/program/gsoc2009/docs/faqs">Program FAQs</a>
+         </li>
+         <li>
+<a href="/program/gsoc2009/docs/tos">Terms of Service</a>
+         </li>
+        </ul>
+       </li>
+       <li>
+<a href="/program/ghop2008/home">Google Highly Open Participation</a>
+        <ul>
+         <li>
+<a href="/program/ghop2008/community">Community</a>
+         </li>
+         <li>
+<a href="/program/ghop2008/docs/faqs">Program FAQs</a>
+         </li>
+         <li>
+<a href="/program/ghop2008/docs/rules">Contest Rules</a>
+         </li>
+        </ul>
+       </li>
+      </ul>
+     </li>
+    </ul>
+{% endblock %}
+   </div>
+
+   <div id="search">
+	{% block sidebar_search_field %}
+    <form id="searchbox_015986126177484454297:pfmwlvdl42y" action="http://www.google.com/cse">
+     <input type="hidden" name="cx" value="015986126177484454297:pfmwlvdl42y" />
+     <input type="hidden" name="cof" value="FORID:0" />
+     <div class="header">
+Search Google Open Source:
+     </div>
+     <input name="q" type="text" size="20" />
+     <input type="submit" name="sa" value="Search" />
+     <br/>
+    </form>
+    <script type="text/javascript" src="http://google.com/coop/cse/brand?form=searchbox_015986126177484454297:pfmwlvdl42y">
+    </script></form>
+	{% endblock %}
+   </div>
+
+   <div id="badge">
+	{% block badge %}
+<a href="http://code.google.com/p/soc/" target="_blank">Powered by Melange</a>
+   <span title=" TODO: need a Melange logo " class="popup">
+<small>*</small>
+   </span>
+	{% endblock %}
+   </div>
+  </div>
+
+  <div id="body">
+	
+   <div style="line-height: 140%;">
+	{% block body %}
+<p class="todo">
+This is generic HTML that can be configured via the site administration
+interface.  It is unclear if the site admin can be trusted and allowed to enter
+any arbitrary HTML (more flexible and powerful) or if only a whitelist of "safe"
+HTML tags should be permitted (to prevent XSS, etc.).
+(<a href="http://www.feedparser.org/"><code>feedparser</code></a> is useful for
+this and is written in Python, should whitelisting be necessary.)
+</p>
+<p>
+Welcome to Google Open Source Programs, the home of
+<a href="/program/gsoc2009/home">Google Summer of Code</a>
+and the
+<a href="/program/ghop2008/home">Google Highly Open Participation</a> contest.
+</p>
+<p class="todo">
+The site administration interface will provide a mechanism to select a feed to
+be displayed here.
+</p>
+	{% endblock %}
+   </div>
+
+	
+   <div id="footer" dir="ltr">
+    <div class="text">
+	{% block footer %}
+&copy;2008 Google -
+<a href="http://www.google.com/">Google Home</a> -
+<a href="http://www.google.com/privacy.html">Privacy Policy</a>
+	{% endblock %}
+    </div>
+   </div>
+  </div>
+
+{% block google_analytics %}
+  <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+  </script>
+
+  <script type="text/javascript">
+_uacct="UA-4291635-1"; // code.google.com site-wide tracking
+_uanchor=1;
+_uff=0;
+urchinTracker();
+  </script>
+{% endblock %}
+ </body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/templates/soc/site/home.html	Tue Aug 19 17:57:58 2008 +0000
@@ -0,0 +1,35 @@
+{% extends "soc/base.html" %}
+{% comment %}
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+
+{% block scripts %}
+    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
+    <script type="text/javascript" src="/soc/content/js/blog.js"></script>
+    <script type="text/javascript">
+
+    google.load("feeds", "1");
+
+    function initialize() {
+      var blog = new BlogPreview(document.getElementById("blog"));
+      blog.show("http://google-opensource.blogspot.com/feeds/posts/default");
+    }
+    google.setOnLoadCallback(initialize);
+
+    </script>
+{% endblock %}
+
+{% block body %}
+	{{ block.super }}
+    <div id="blog"></div>
+{% endblock %}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/soc/views/site/home.py	Tue Aug 19 17:57:58 2008 +0000
@@ -0,0 +1,43 @@
+#!/usr/bin/python2.5
+#
+# Copyright 2008 the Melange authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Melange home page
+"""
+
+__authors__ = [
+  '"Pawel Solyga" <pawel.solyga@gmail.com>',
+  ]
+
+
+from google.appengine.api import users
+from django import http
+from django import shortcuts
+
+def public(request, template='soc/site/home.html'):
+  """Home site view of Melange.
+
+  Args:
+    request: the standard django request object.
+    template: the template path to use for rendering the template.
+
+  Returns:
+    A subclass of django.http.HttpResponse with generated template.
+  """
+	
+  user = users.get_current_user()
+
+  return shortcuts.render_to_response(
+      template, dictionary={'template': template, 'user': user})
--- a/app/urls.py	Tue Aug 19 17:52:13 2008 +0000
+++ b/app/urls.py	Tue Aug 19 17:57:58 2008 +0000
@@ -14,6 +14,7 @@
 
 __authors__ = [
   '"Augie Fackler" <durin42@gmail.com>',
+  '"Pawel Solyga" <pawel.solyga@gmail.com>',
   ]
 
 
@@ -22,6 +23,7 @@
 
 urlpatterns = patterns(
     '',
+    (r'^$', 'soc.views.site.home.public'),
     (r'^org/profile/(?P<program>ghop[_0-9a-z]+)/(?P<linkname>[_0-9a-z]+)/$',
      'soc.views.person.profile.edit',
      {'template': 'ghop/person/profile/edit.html'}),