# HG changeset patch # User Pawel Solyga # Date 1219168678 0 # Node ID 58001ec7720c7ca9b015b64c0a91f414f4ea9377 # Parent 206e6eeed6c48a1eca37d7080bd7e5279e4b89c8 Home site templates and basic view. Patch by: Pawel Solyga Review by: Todd Larsen Review issue: 385 Review URL: http://codereviews.googleopensourceprograms.com/385 diff -r 206e6eeed6c4 -r 58001ec7720c AUTHORS --- 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" "Sverre Rabbelier" - +"Pawel Solyga" diff -r 206e6eeed6c4 -r 58001ec7720c app/soc/content/css/soc.css --- 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; +} diff -r 206e6eeed6c4 -r 58001ec7720c app/soc/content/js/blog.js --- /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; +} + diff -r 206e6eeed6c4 -r 58001ec7720c app/soc/templates/soc/base.html --- /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 %} + + + + + {% block stylesheet %} + + {% endblock %} + {% block page_title %}Google Open Source Programs{% endblock %} + {% block scripts %}{% endblock %} + + + + + +
+ {% block login_links %} + Report bugs | + Sign in + {% endblock %} +
+ + + +
+ + + + +
+ {% block badge %} +Powered by Melange + +* + + {% endblock %} +
+
+ +
+ +
+ {% block body %} +

+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.). +(feedparser is useful for +this and is written in Python, should whitelisting be necessary.) +

+

+Welcome to Google Open Source Programs, the home of +Google Summer of Code +and the +Google Highly Open Participation contest. +

+

+The site administration interface will provide a mechanism to select a feed to +be displayed here. +

+ {% endblock %} +
+ + + +
+ +{% block google_analytics %} + + + +{% endblock %} + + diff -r 206e6eeed6c4 -r 58001ec7720c app/soc/templates/soc/site/home.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 %} + + + +{% endblock %} + +{% block body %} + {{ block.super }} +
+{% endblock %} \ No newline at end of file diff -r 206e6eeed6c4 -r 58001ec7720c app/soc/views/site/__init__.py diff -r 206e6eeed6c4 -r 58001ec7720c app/soc/views/site/home.py --- /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" ', + ] + + +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}) diff -r 206e6eeed6c4 -r 58001ec7720c app/urls.py --- 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" ', + '"Pawel Solyga" ', ] @@ -22,6 +23,7 @@ urlpatterns = patterns( '', + (r'^$', 'soc.views.site.home.public'), (r'^org/profile/(?Pghop[_0-9a-z]+)/(?P[_0-9a-z]+)/$', 'soc.views.person.profile.edit', {'template': 'ghop/person/profile/edit.html'}),