예제 #1
0
파일: project.py 프로젝트: Etenil/anvil
 def branch_rss(self, project, branch):
     feed = anvillib.bzr.get_project_branch_rss(project, branch)
     link = "http://%s/%s/%s/branch/%s" % (config.val("host"), config.val("prefix"), project, branch)
     link = link.replace("//", "/")
     feed = feed.replace("$l", link)
     web.header("Content-Type", "text/xml")
     return common.render.rss(link=link, feed=feed, htTitle="Branch " + branch)
예제 #2
0
파일: acls.py 프로젝트: Etenil/anvil
 def __init__(self, project_id):
     db = MySQLdb.connect(host=config.val('db.host'),
                          user=config.val('db.user'),
                          passwd=config.val('db.pwd'),
                          db=config.val('db.name'))
     c = db.cursor()
     c.execute("SELECT * FROM `project` WHERE id=%s", project_id)
     row = c.fetchone()
     self.projectname = row[1]
예제 #3
0
파일: acls.py 프로젝트: Etenil/anvil
 def __init__(self, user_id):
     self.db = MySQLdb.connect(host=config.val('db.host'),
                               user=config.val('db.user'),
                               passwd=config.val('db.pwd'),
                               db=config.val('db.name'))
     c = self.db.cursor()
     c.execute("SELECT * FROM user WHERE id=%s", user_id)
     row = c.fetchone()
     self.user_id = user_id
     self.username = row[1]
예제 #4
0
파일: project.py 프로젝트: Etenil/anvil
 def events_rss(self, projectname):
     try:
         proj = model.project.Project(name=projectname)
         activity = model.event.get_project_events(proj.id, 0, 30)
         web.header("Content-Type", "text/xml")
         link = "http://%s/%s/%s" % (config.val("host"), config.val("prefix"), projectname)
         link = link.replace("//", "/")
         return common.render.eventsrss(
             is_main=False, project=proj, activity=activity, htTitle="Events for project %s" % projectname, link=link
         )
     except:
         web.header("Content-Type", "text/html")
         return web.notfound()
예제 #5
0
파일: user.py 프로젝트: Etenil/anvil
 def branch_rss(self, username, branch):
     user = model.user.User(name=username)
     canedit = (common.session.user == user.name)
     feed = anvillib.bzr.get_user_branch_rss(user.name, branch)
     link = "http://%s/%s/*%s/branch/%s" % (config.val('host'),
                                    config.val('prefix'),
                                    username, branch)
     link = link.replace("//", "/")
     feed = feed.replace("$l", link)
     web.header('Content-Type', 'text/xml')
     return common.render.rss(link=link,
                              feed=feed,
                              htTitle="Branch " + branch)
예제 #6
0
파일: user.py 프로젝트: Etenil/anvil
 def do_register(self):
     f = self.reg_form()
     if not f.validates():
         return common.render.register(form=f,
                                       htTitle="Register")
     i = web.input()
     try:
         # Creating the user on the system
         anvillib.fs.create_user(i.name)
         # Adding the user
         model.user.create_user(name=i.name,
                                email=i.email,
                                password=i.password,
                                homepage=i.homepage,
                                description=i.description)
         common.session.user = i.name
         event.add(username=i.name, type=event.EV_USER,
                   link=config.prefix + '/*' + i.name,
                   msg=("%s registered to %s" % (i.name, config.val('title'))))
         email.send("*****@*****.**", i.email, "Welcome to Anvil",
                    """Thank you for registering on Anvil.""")
         raise web.seeother(config.prefix + '/*' + i.name)
     except model.user.UserError:
         return common.render.register(error="Username already exists!",
                                form=f,
                                htTitle="Register")
예제 #7
0
파일: user.py 프로젝트: Etenil/anvil
 def events_rss(self, username):
     try:
         user = model.user.User(name=username)
         activity = model.event.get_user_events(user.id, 0, 30)
         web.header('Content-Type', 'text/xml')
         link = "http://%s/%s/*%s" % (config.val('host'),
                                      config.val('prefix'),
                                      username)
         link = link.replace("//", "/")
         return common.render.eventsrss(is_main=False,
                                        user=user,
                                        activity=activity,
                                        htTitle="Events for %s" % username,
                                        link=link)
     except:
         web.header('Content-Type', 'text/html')
         return web.notfound()
예제 #8
0
파일: anvil.py 프로젝트: Etenil/anvil
 def GET(self):
     activity = model.event.get_events(0, 30)
     custom_logged_page=None
     custom_visitor_page=None
     if os.path.exists("custom.logged.html"):
         f = open("custom.logged.html")
         custom_logged_page = f.read()
         f.close()
     if os.path.exists("custom.visitor.html"):
         f = open("custom.visitor.html")
         custom_visitor_page = f.read()
         f.close()
     return common.render.main(content="Welcome to " + config.val('title'),
                               is_main=True,
                               num_proj=model.project.count_proj(),
                               activity=activity,
                               custom_logged_page=custom_logged_page,
                               custom_visitor_page=custom_visitor_page,
                               htTitle="Welcome to " + config.val('title') + "!")
예제 #9
0
파일: anvil.py 프로젝트: Etenil/anvil
from controller.project import Project
from controller.message import Message
from controller.bug import Bug
from controller.doc import Doc

import model.project
import model.message
import model.event
from anvillib import config

### Parsing the configuration
config.load_conf()

# Generating an argv from the config file (for web.py; pretty dirty I
# know).
sys.argv = ['anvil.py', config.val('port')]

### URL mapping

urls = (
    '/'                                                          , 'Main',
    '/(login)'                                                   , 'User',
    '/(logout)'                                                  , 'User',
    '/(register)'                                                , 'User',
    '/(profile)'                                                 , 'User',
    '/(users)'                                                   , 'User',
    '/message(?:/(.+))?$'                                        , 'Message',
    '/ajax/(listusers)'                                          , 'User',
    '/project(?:/(.+))?$'                                        , 'Project',
    '/\*([a-z0-9._-]+)$'                                         , 'User',
    '/\*([a-z0-9._-]+)/(key)(?:/(.+?)(?:/(.+))?)?$'              , 'User',
예제 #10
0
파일: common.py 프로젝트: Etenil/anvil
import web
import os
from anvillib import config
from web.contrib.template import render_mako

web.config.debug = False
web.config.debug_sql = False

# Common variables.
db = web.database(dbn='mysql', user=config.val('db.user'),
                  pw=config.val('db.pwd'), db=config.val('db.name'))
session = None
env_info = None
msgs = None
render = render = render_mako(
    directories=['templates'],
    input_encoding='utf-8',
    output_encoding='utf-8',
    )

os.environ['SCRIPT_NAME'] = config.val('prefix')
os.environ['REAL_SCRIPT_NAME'] = config.val('prefix')