Commits

Mirko Darino  committed ae518eb

Initial commit

  • Participants

Comments (0)

Files changed (38)

+recursive-include userprofile/public *
+recursive-include userprofile/templates *.html
+global-exclude *.pyc
+
+About userprofile
+-------------------------
+
+userprofile is a Pluggable application for TurboGears2.
+
+Installing
+-------------------------------
+
+userprofile can be installed both from pypi or from bitbucket::
+
+    easy_install userprofile
+
+should just work for most of the users
+
+Plugging userprofile
+----------------------------
+
+In your application *config/app_cfg.py* import **plug**::
+
+    from tgext.pluggable import plug
+
+Then at the *end of the file* call plug with registration::
+
+    plug(base_config, 'userprofile')
+
+You will be able to access the registration process at
+*http://localhost:8080/userprofile*.
+
+Available Hooks
+----------------------
+
+userprofile makes available a some hooks which will be
+called during some actions to alter the default
+behavior of the appplications:
+
+Exposed Partials
+----------------------
+
+userprofile exposes a bunch of partials which can be used
+to render pieces of the blogging system anywhere in your
+application:
+
+Exposed Templates
+--------------------
+
+The templates used by registration and that can be replaced with
+*tgext.pluggable.replace_template* are:
+
+# -*- coding: utf-8 -*-
+import sys, os
+
+try:
+    from setuptools import setup, find_packages
+except ImportError:
+    from ez_setup import use_setuptools
+    use_setuptools()
+    from setuptools import setup, find_packages
+
+install_requires=[
+    "TurboGears2 >= 2.1.4",
+    "tgext.pluggable"
+]
+
+here = os.path.abspath(os.path.dirname(__file__))
+try:
+    README = open(os.path.join(here, 'README.rst')).read()
+except IOError:
+    README = ''
+
+setup(
+    name='userprofile',
+    version='0.1',
+    description='',
+    long_description=README,
+    author='',
+    author_email='',
+    #url='',
+    keywords='turbogears2.application',
+    setup_requires=["PasteScript >= 1.7"],
+    paster_plugins=[],
+    packages=find_packages(exclude=['ez_setup']),
+    install_requires=install_requires,
+    include_package_data=True,
+    package_data={'tgapp.userprofile': ['i18n/*/LC_MESSAGES/*.mo',
+                                 'templates/*/*',
+                                 'public/*/*']},
+    entry_points="""
+    """,
+    dependency_links=[
+        "http://www.turbogears.org/2.1/downloads/current/"
+        ],
+    zip_safe=False
+)

File userprofile.egg-info/PKG-INFO

+Metadata-Version: 1.0
+Name: userprofile
+Version: 0.1
+Summary: UNKNOWN
+Home-page: UNKNOWN
+Author: UNKNOWN
+Author-email: UNKNOWN
+License: UNKNOWN
+Description: About userprofile
+        -------------------------
+        
+        userprofile is a Pluggable application for TurboGears2.
+        
+        Installing
+        -------------------------------
+        
+        userprofile can be installed both from pypi or from bitbucket::
+        
+            easy_install userprofile
+        
+        should just work for most of the users
+        
+        Plugging userprofile
+        ----------------------------
+        
+        In your application *config/app_cfg.py* import **plug**::
+        
+            from tgext.pluggable import plug
+        
+        Then at the *end of the file* call plug with registration::
+        
+            plug(base_config, 'userprofile')
+        
+        You will be able to access the registration process at
+        *http://localhost:8080/userprofile*.
+        
+        Available Hooks
+        ----------------------
+        
+        userprofile makes available a some hooks which will be
+        called during some actions to alter the default
+        behavior of the appplications:
+        
+        Exposed Partials
+        ----------------------
+        
+        userprofile exposes a bunch of partials which can be used
+        to render pieces of the blogging system anywhere in your
+        application:
+        
+        Exposed Templates
+        --------------------
+        
+        The templates used by registration and that can be replaced with
+        *tgext.pluggable.replace_template* are:
+        
+        
+Keywords: turbogears2.application
+Platform: UNKNOWN

File userprofile.egg-info/SOURCES.txt

+MANIFEST.in
+setup.py
+userprofile/__init__.py
+userprofile/bootstrap.py
+userprofile/helpers.py
+userprofile/partials.py
+userprofile.egg-info/PKG-INFO
+userprofile.egg-info/SOURCES.txt
+userprofile.egg-info/dependency_links.txt
+userprofile.egg-info/entry_points.txt
+userprofile.egg-info/not-zip-safe
+userprofile.egg-info/paster_plugins.txt
+userprofile.egg-info/requires.txt
+userprofile.egg-info/top_level.txt
+userprofile/controllers/__init__.py
+userprofile/controllers/root.py
+userprofile/lib/__init__.py
+userprofile/model/__init__.py
+userprofile/model/models.py
+userprofile/public/__init__.py
+userprofile/public/css/style.css
+userprofile/public/images/star.png
+userprofile/templates/__init__.py
+userprofile/templates/index.html
+userprofile/templates/little_partial.html

File userprofile.egg-info/dependency_links.txt

+http://www.turbogears.org/2.1/downloads/current/

File userprofile.egg-info/entry_points.txt

+
+    

File userprofile.egg-info/not-zip-safe

+

File userprofile.egg-info/paster_plugins.txt

+

File userprofile.egg-info/requires.txt

+TurboGears2 >= 2.1.4
+tgext.pluggable

File userprofile.egg-info/top_level.txt

+userprofile

File userprofile/__init__.py

+# -*- coding: utf-8 -*-
+"""The userprofile package"""
+
+def plugme(app_config, options):
+    app_config['_pluggable_userprofile_config'] = options
+    return dict(appid='userprofile', global_helpers=False)

File userprofile/__init__.pyc

Binary file added.

File userprofile/bootstrap.py

+# -*- coding: utf-8 -*-
+"""Setup the userprofile application"""
+
+from userprofile import model
+from tgext.pluggable import app_model
+
+def bootstrap(command, conf, vars):
+    print 'Bootstrapping userprofile...'
+
+    s1 = model.Sample()
+    s1.name = 'Test Sample'
+    s1.user = model.DBSession.query(app_model.User).first()
+
+    model.DBSession.add(s1)
+    model.DBSession.flush()

File userprofile/bootstrap.pyc

Binary file added.

File userprofile/controllers/__init__.py

+# -*- coding: utf-8 -*-
+"""Controllers for the userprofile pluggable application."""
+
+from root import RootController

File userprofile/controllers/__init__.pyc

Binary file added.

File userprofile/controllers/root.py

+# -*- coding: utf-8 -*-
+"""Main Controller"""
+
+from tg import TGController
+from tg import expose, flash, require, url, lurl, request, redirect, validate, config
+from tg.i18n import ugettext as _, lazy_ugettext as l_
+from tg.exceptions import HTTPNotFound
+
+from userprofile import model
+from userprofile.model import DBSession
+from amolamusica.model.auth import User
+
+from tgext.pluggable import plug_url
+
+class RootController(TGController):
+    @expose('userprofile.templates.index')
+    def default(self, uid):
+        user = DBSession.query(User).filter_by(user_id=uid).first()
+        if not user:
+            raise HTTPNotFound()
+
+        user_data = getattr(user, 'profile_data', {'display_name':user.display_name,
+                                                   'Username':user.user_name, 
+                                                   'Email Address':user.email_address})
+
+        user_displayname = user_data.pop('display_name', 'Unknown')
+
+        user_avatar = user_data.pop('avatar', None)
+        if user_avatar is None:
+            fbauth_info = getattr(user, 'fbauth', None)
+            if fbauth_info is not None:
+                user_avatar = fbauth_info.profile_picture + '?type=large'
+            else:
+                user_avatar = url('/_pluggable/userprofile/images/default_avatar.jpg')
+
+        profile_css = url(config['_pluggable_userprofile_config'].get('custom_css',
+                                                                      '/_pluggable/userprofile/css/style.css'))
+
+        user_partial = config['_pluggable_userprofile_config'].get('user_partial')
+
+        return dict(user_data=user_data, user_avatar=user_avatar, user_displayname=user_displayname,
+                    profile_css=profile_css, user_partial=user_partial)

File userprofile/controllers/root.pyc

Binary file added.

File userprofile/helpers.py

+# -*- coding: utf-8 -*-
+
+"""WebHelpers used in userprofile."""
+
+from webhelpers import date, feedgenerator, html, number, misc, text
+
+def bold(text):
+    return html.literal('<strong>%s</strong>' % text)

File userprofile/helpers.pyc

Binary file added.

File userprofile/lib/__init__.py

+# -*- coding: utf-8 -*-
+

File userprofile/lib/__init__.pyc

Binary file added.

File userprofile/model/__init__.py

+# -*- coding: utf-8 -*-
+from sqlalchemy.ext.declarative import declarative_base
+from tgext.pluggable import PluggableSession
+
+DBSession = PluggableSession()
+DeclarativeBase = declarative_base()
+
+def init_model(app_session):
+    DBSession.configure(app_session)
+
+from models import Sample
+

File userprofile/model/__init__.pyc

Binary file added.

File userprofile/model/models.py

+from sqlalchemy import Table, ForeignKey, Column
+from sqlalchemy.types import Unicode, Integer, DateTime
+from sqlalchemy.orm import backref, relation
+
+from userprofile.model import DeclarativeBase
+from tgext.pluggable import app_model, primary_key
+
+class Sample(DeclarativeBase):
+    __tablename__ = 'userprofile_samples'
+
+    uid = Column(Integer, autoincrement=True, primary_key=True)
+    name = Column(Unicode(16))
+
+    user_id = Column(Integer, ForeignKey(primary_key(app_model.User)))
+    user = relation(app_model.User)
+

File userprofile/model/models.pyc

Binary file added.

File userprofile/partials.py

+from tg import expose
+
+@expose('userprofile.templates.little_partial')
+def something(name):
+    return dict(name=name)

File userprofile/partials.pyc

Binary file added.

File userprofile/public/__init__.py

+# -*- coding: utf-8 -*-
+"""Enable statics for the userprofile package"""

File userprofile/public/__init__.pyc

Binary file added.

File userprofile/public/css/style.css

+#userprofile_container {
+    width: 500px;
+    margin: 0 auto;
+    background-color: white;
+    border: solid 1px black;
+}
+
+#userprofile_avatar_container {
+    border: solid 1px gray;
+    margin: 10px;
+}
+
+#userprofile_avatar_container img {
+    width: 120px;
+    display: block;
+}
+
+#userprofile_info_container {
+    margin-top: 10px;
+}
+
+#userprofile_avatar_container, #puserrofile_info_container {
+    float: left;
+}
+
+#userprofile_title {
+    font-weight: bolder;
+    font-size: 20px;
+    color: blue;
+    margin-bottom: 15px;
+}
+
+.userprofile_user_attr_title {
+    font-weight: bold;
+    margin-right: 5px;
+}
+
+#userprofile_end {
+    clear: both;
+}

File userprofile/public/images/defaul_avatar.jpg

Added
New image

File userprofile/public/images/star.png

Added
New image

File userprofile/templates/__init__.py

+# -*- coding: utf-8 -*-
+"""Templates package for the application."""

File userprofile/templates/__init__.pyc

Binary file added.

File userprofile/templates/index.html

+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:py="http://genshi.edgewall.org/"
+      xmlns:xi="http://www.w3.org/2001/XInclude">
+
+  <xi:include href="master.html" />
+
+<head>
+  <title>${user_displayname} Profile</title>
+  <link rel="stylesheet" type="text/css" media="screen" href="${profile_css}" />
+</head>
+
+<body>
+    <div id="userprofile_container">
+        <div id="userprofile_avatar_container">
+            <img id="userprofile_avatar" src="${user_avatar}" />
+        </div>
+        <div id="userprofile_info_container">
+            <div id="userprofile_title">${user_displayname}</div>
+            <div id="userprofile_other_attr">
+                <div py:for="attr_name, attr_value in user_data.items()" 
+                     id="userprofile_user_attr_${attr_name}" class="userprofile_user_attr">
+                    <span class="userprofile_user_attr_title">${attr_name}:</span>
+                    <span class="userprofile_user_attr_value">${attr_value}</span>
+                </div>
+            </div>
+            <div py:if="user_partial">
+                ${h.call_partial(user_partial, name='Partial')}
+            </div>
+        </div>
+        <div id="userprofile_end"></div>
+    </div>
+</body>
+</html>

File userprofile/templates/little_partial.html

+<div xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:py="http://genshi.edgewall.org/"
+      xmlns:xi="http://www.w3.org/2001/XInclude">
+    <div>This is from partial: ${h.userprofile.bold(name)}</div>
+</div>