示例#1
0
文件: main.py 项目: drewp/theory
    def artists(self):
        """ the controller for the artists frame """

        try:
            self.m = g.p.connect()
        except (NoMPDConnection, ConnectionClosed):
            return render('/null.html')

        c.artists = self.m.artists()
        return render('/artists.html')
示例#2
0
    def artists(self):
        """ the controller for the artists frame """

        try:
            self.m = g.p.connect()
        except (NoMPDConnection, ConnectionClosed):
            return render('/null.html')

        c.artists = self.m.artists()
        return render('./artists.html')
示例#3
0
文件: main.py 项目: goosemo/theory
    def streams(self,use_htmlfill=True,**kwargs):
        c.error = request.GET.get('error','')
        c.streams = g.tc.streams

        if use_htmlfill:
            return formencode.htmlfill.render(render("/streams.html"),{'name':kwargs.get('name',''),
                                                                       'url':kwargs.get('url','')})
        else:
            return render("/streams.html")
        return render('/streams.html')
示例#4
0
文件: main.py 项目: goosemo/theory
    def artists(self):
        """ the controller for the artists frame """

        try:
            m = g.p.connect()
        except ConnectionClosed:
            return render('/null.html')

        c.artists = m.artists()
        return render('/artists.html')
示例#5
0
    def streams(self, use_htmlfill=True, **kwargs):
        c.error = request.GET.get('error', '')
        c.streams = g.tc.streams

        if use_htmlfill:
            return formencode.htmlfill.render(render("/streams.html"), {'name':kwargs.get('name',''),
                                                                       'url':kwargs.get('url', '')})
        else:
            return render("/streams.html")
        return render('/streams.html')
示例#6
0
    def stats(self):
        """ controller for the stats widget """

        try:
            self.m = g.p.connect()
        except (NoMPDConnection, ConnectionClosed):
            return render('/null.html')

        c.stats = self.m.stats()
        aa = AlbumArt()
        c.dir_size = aa.dir_size()

        return render('/stats.html')
示例#7
0
文件: main.py 项目: goosemo/theory
    def stats(self):
        """ controller for the stats widget """

        try:
            m = g.p.connect()
        except ConnectionClosed:
            return render('/null.html')

        c.stats = m.stats()
        aa = AlbumArt()
        c.dir_size = aa.dir_size()

        return render('/stats.html')
示例#8
0
    def tracks(self):
        """ controller for the tracks frame """

        c.artist = request.GET.get('artist', '').encode('utf-8')
        c.album = request.GET.get('album', '').encode('utf-8')
        try:
            self.m = g.p.connect()
        except (NoMPDConnection, ConnectionClosed):
            return render('/null.html')

        c.tracks = self.m.tracks(c.artist, c.album)

        c.artist_safe = h.html.url_escape(c.artist)
        c.album_safe = h.html.url_escape(c.album)

        return render('/tracks.html')
示例#9
0
    def fs_status(self):
        """
        similar to status() but includes a forward-looking playlist
        for the fullscreen widget
        """

        try:
            self.m = g.p.connect()
        except ConnectionClosed:
            return render('/null.html')

        status = self.m.status()
        current = self.m.currentsong()
        playlist = self.m.playlistinfo()

        track = 0
        found_current = False
        remaining_playlist = []

        for pl in playlist:
            if found_current:
                remaining_playlist.append(pl)

            if 'id' in current:
                if pl['id'] == current['id']:
                    found_current = True

            track += 1

        #m.close()
        return dict(status=status,current=current,playlist=remaining_playlist)
示例#10
0
    def fs_status(self):
        """ 
        similar to status() but includes a forward-looking playlist 
        for the fullscreen widget
        """

        try:
            self.m = g.p.connect()
        except ConnectionClosed:
            return render('/null.html')

        status = self.m.status()
        current = self.m.currentsong()
        playlist = self.m.playlistinfo()

        track = 0
        found_current = False
        remaining_playlist = []

        for pl in playlist:
            if found_current:
                remaining_playlist.append(pl)

            if 'id' in current:
                if pl['id'] == current['id']:
                    found_current = True

            track += 1

        #m.close()
        return dict(status=status,
                    current=current,
                    playlist=remaining_playlist)
示例#11
0
    def albums(self):
        """ controller for the albums frame """

        c.artist = request.GET.get('artist', '').encode('utf-8')
        c.album = request.GET.get('album', '').encode('utf-8')

        try:
            self.m = g.p.connect()
        except (NoMPDConnection, ConnectionClosed):
            return render('/null.html')
        c.albums = self.m.albums(c.artist)

        aa = AlbumArt()
        c.album_imgs = aa.artist_art(c.artist)
        random.shuffle(c.album_imgs)
        return render('/albums.html')
示例#12
0
    def index(self):
        """ controller for the playlist frame """

        try:
            self.m = g.p.connect()
        except NoMPDConnection:            
            return render('/null.html')
        status = self.m.status()
        c.playlistid = status['playlist']
        c.playlist = self.m.playlistinfo()
        info = self.m.lsinfo()
        c.available_playlists = [playlist['playlist'] for playlist in info if 'playlist' in playlist]
        c.available_playlists.insert(0,'')
        c.g = g

        return render('/playlist.html')
示例#13
0
文件: main.py 项目: goosemo/theory
    def search(self):
        searchtype = request.GET.get('searchtype','Artist')
        q = request.GET.get('q').encode('utf-8')

        if q and len(q) > 2:
            m = g.p.connect()
            results = m.search(searchtype,q)

            c.artists = set()
            c.albums = set()
            c.tracks = set()

            search_string = q.lower()

            for r in results:
                if 'artist' in r.keys() and search_string in r['artist'].lower():
                    c.artists.add(r['artist'])

                if 'album' in r.keys() and search_string in r['album'].lower():
                    c.albums.add((r['artist'], r['album']))

                if 'title' in r.keys() and search_string in r['title'].lower():
                    c.tracks.add((r['artist'], r['album'], r['title'], r['file']))

        return render('/search.html')
示例#14
0
文件: main.py 项目: goosemo/theory
    def albums(self):
        """ controller for the albums frame """

        c.artist = request.GET.get('artist','').encode('utf-8')
        c.album = request.GET.get('album','').encode('utf-8')

        try:
            m = g.p.connect()
        except ConnectionClosed:
            return render('/null.html')
        c.albums = m.albums(c.artist)

        aa = AlbumArt()
        c.album_imgs = aa.artist_art(c.artist)
        random.shuffle(c.album_imgs)
        return render('/albums.html')
示例#15
0
文件: main.py 项目: goosemo/theory
    def tracks(self):
        """ controller for the tracks frame """

        c.artist = request.GET.get('artist','').encode('utf-8')
        c.album = request.GET.get('album','').encode('utf-8')
        try:
            m = g.p.connect()
        except ConnectionClosed:
            return render('/null.html')

        c.tracks = m.tracks(c.artist,c.album)

        c.artist_safe = h.html.url_escape(c.artist)
        c.album_safe = h.html.url_escape(c.album)

        return render('/tracks.html')
示例#16
0
    def search(self):
        searchtype = request.GET.get('searchtype', 'Artist')
        q = request.GET.get('q').encode('utf-8')

        if q and len(q) > 2:
            self.m = g.p.connect()
            results = self.m.search(searchtype, q)

            c.artists = set()
            c.albums = set()
            c.tracks = set()

            search_string = q.lower()

            for r in results:
                if 'artist' in r.keys() and search_string in r['artist'].lower():
                    c.artists.add(r['artist'])

                if 'album' in r.keys() and search_string in r['album'].lower():
                    c.albums.add((r['artist'], r['album']))

                if 'title' in r.keys() and search_string in r['title'].lower():
                    c.tracks.add((r['artist'], r['album'], r['title'], r['file']))

        return render('/search.html')
示例#17
0
    def albums(self):
        """ controller for the albums frame """

        c.artist = request.GET.get('artist', u'')
        c.album = request.GET.get('album', u'')

        try:
            self.m = g.p.connect()
        except (NoMPDConnection, ConnectionClosed):
            return render('/null.html')
        c.albums = self.m.albums(c.artist)

        aa = AlbumArt()
        c.album_imgs = aa.artist_art(c.artist)
        random.shuffle(c.album_imgs)
        return render('/albums.html')
示例#18
0
文件: main.py 项目: goosemo/theory
    def add_random(self):
        m = g.p.connect()
        files = request.POST.getall('file')
        for f in files:
            m.add(f.encode('utf-8'))

        c.content = '<script language="javascript">window.parent.frames[\'frmplaylist\'].location.reload();</script>'
        return render('/null.html')
示例#19
0
文件: main.py 项目: goosemo/theory
    def filesystem(self):
        m = g.p.connect()
        c.path = request.GET.get('path','/').encode('utf-8')
        c.lsinfo = m.lsinfo(c.path)

        c.uppath = '/'.join(c.path.split('/')[:-1])

        return render('/filesystem.html')
示例#20
0
    def filesystem(self):
        self.m = g.p.connect()
        c.path = request.GET.get('path', '/').encode('utf-8')
        c.lsinfo = self.m.lsinfo(c.path)

        c.uppath = '/'.join(c.path.split('/')[:-1])

        return render('/filesystem.html')
示例#21
0
    def add_random(self):
        self.m = g.p.connect()
        files = request.POST.getall('file')
        for f in files:
            self.m.add(f.encode('utf-8'))

        c.content = '<script language="javascript">window.parent.frames[\'frmplaylist\'].location.reload();</script>'
        return render('/null.html')
示例#22
0
    def randomizer(self):
        action = request.GET.get('action', '')
        c.incex = request.GET.get('incex', 'exclude')
        c.selected_genres = request.GET.getall('genres') 
        c.exclude_live = request.GET.get('excludelive', not bool(len(action)))
        c.quantity = int(request.GET.get('quantity', 50))
        c.genres = sorted(g.genres)

        if action:
            self.m = g.p.connect()
            c.random_tracks = self.m.get_random_tracks(c.incex, c.selected_genres, c.exclude_live, c.quantity)
        return render('/randomizer.html')
示例#23
0
文件: main.py 项目: goosemo/theory
    def randomizer(self):
        action = request.GET.get('action','')
        c.incex = request.GET.get('incex','exclude')
        c.selected_genres = request.GET.getall('genres') 
        c.exclude_live = request.GET.get('excludelive',not bool(len(action)))
        c.quantity = int(request.GET.get('quantity',50))
        c.genres = sorted(g.genres)

        if action:
            m = g.p.connect()
            c.random_tracks = m.get_random_tracks(c.incex,c.selected_genres,c.exclude_live,c.quantity)
        return render('/randomizer.html')
示例#24
0
    def document(self):
        """Render the error document"""
        resp = request.environ.get('pylons.original_response')

        if resp.status_int == 404:
            return render('/404.html')

        content = literal(resp.body) or cgi.escape(request.GET.get('message'))
        page = error_document_template % \
            dict(prefix=request.environ.get('SCRIPT_NAME', ''),
                 code=cgi.escape(request.GET.get('code', str(resp.status_int))),
                 message=content)
        return page
示例#25
0
    def config(self, use_htmlfill=True):
        """ controller for the configuration iframe """

        c.firsttime = request.GET.get('firsttime', '0')
        c.noconnection = request.GET.get('noconnection')
        c.error = request.GET.get('error')
        c.type = request.GET.get('type')

        configured_outputs = []

        if c.firsttime == '0':
            try:
                self.m = g.p.connect()
                c.outputs = self.m.outputs()

                for o in c.outputs:
                    if o['outputenabled'] == '1':
                        key = 'enabled'
                    else:
                        key = 'disabled'

                    configured_outputs.append({key: o['outputid']})

            except ConnectionClosed:
                return render('/null.html')

        if use_htmlfill:
            values = formencode.variabledecode.variable_encode({'firsttime': c.firsttime, 'server':g.tc.server,
                                                                'port':g.tc.port,
                                                                'password':g.tc.password,'webpassword':g.tc.webpassword,
                                                                'awskey':g.tc.awskey,'timeout':g.tc.timeout,
                                                                'aws_secret':g.tc.aws_secret,
                                                                'lastfmkey':g.tc.lastfmkey,
                                                                'default_search':g.tc.default_search,
                                                                'outputs': configured_outputs})

            return formencode.htmlfill.render(render("/config.html"), values)
        else:
            return render("/config.html")
示例#26
0
文件: error.py 项目: MechanisM/theory
    def document(self):
        """Render the error document"""
        resp = request.environ.get('pylons.original_response')

        if resp.status_int == 404:
            return render('/404.html')

        content = literal(resp.body) or cgi.escape(request.GET.get('message'))
        page = error_document_template % \
            dict(prefix=request.environ.get('SCRIPT_NAME', ''),
                 code=cgi.escape(request.GET.get('code', str(resp.status_int))),
                 message=content)
        return page
示例#27
0
    def config(self, use_htmlfill=True):
        """ controller for the configuration iframe """

        c.firsttime = request.GET.get('firsttime', '0')
        c.noconnection = request.GET.get('noconnection')
        c.error = request.GET.get('error')
        c.type = request.GET.get('type')

        configured_outputs = []

        if c.firsttime == '0':
            try:
                self.m = g.p.connect()
                c.outputs = self.m.outputs()

                for o in c.outputs:
                    if o['outputenabled'] == '1':
                        key = 'enabled'
                    else:
                        key = 'disabled'

                    configured_outputs.append({key: o['outputid']})

            except ConnectionClosed:
                return render('/null.html')

        if use_htmlfill:
            values = formencode.variabledecode.variable_encode({'firsttime': c.firsttime, 'server':g.tc.server,
                                                                'port':g.tc.port,
                                                                'password':g.tc.password,'webpassword':g.tc.webpassword,
                                                                'awskey':g.tc.awskey,'timeout':g.tc.timeout,
                                                                'aws_secret':g.tc.aws_secret,
                                                                'default_search':g.tc.default_search,
                                                                'outputs': configured_outputs})

            return formencode.htmlfill.render(render("/config.html"), values)
        else:
            return render("/config.html")
示例#28
0
   def submit(self):
       """
       Verify password
       """
       form_password = str(request.params.get('password'))

       if form_password != g.tc.webpassword:
           c.err = 1
           return render('/login.html')

       # Mark user as logged in
       session['user'] = '******'
       session.save()

       redirect(url(controller='main', action='index'))
示例#29
0
文件: login.py 项目: goosemo/theory
   def submit(self):
       """
       Verify password
       """
       form_password = str(request.params.get('password'))

       if form_password != g.tc.webpassword:
           c.err = 1
           return render('/login.html')

       # Mark user as logged in
       session['user'] = '******'
       session.save()

       redirect_to(controller='main')
示例#30
0
文件: main.py 项目: goosemo/theory
    def index(self):
        """ the main page controller! """

        c.debug = request.GET.get('debug',0)
        
        try:
            g.p.connect()
        except (ProtocolError,ConnectionClosed):
            if g.tc.server is None:
                g.tc = TConfig()
                if g.tc.server is None:
                    c.config = '/config?firsttime=1'
            else:
                c.config = '/config?noconnection=1'
            pass
        except IncorrectPassword:
            abort(401)

        return render('/index.html')
示例#31
0
    def index(self):
        """ the main page controller! """

        c.debug = request.GET.get('debug', 0)
        c.config = ''
        
        try:
            self.m = g.p.connect()
        except (ProtocolError, ConnectionClosed, NoMPDConnection):
            if g.tc.server is None:
                g.tc = TConfig()
                if g.tc.server is None:
                    c.config = '/config?firsttime=1'
            else:
                c.config = '/config?noconnection=1'
            pass
        except IncorrectPassword:
            abort(401)

        return render('/index.html')
示例#32
0
   def login(self):
       """
       Show login form. Submits to /login/submit
       """

       return render('/login.html')
示例#33
0
    def fullscreen(self):
        """ controller for the fullscreen widget """

        return render('/fullscreen.html')
示例#34
0
 def genre(self):
     c.genre = request.GET.get('genre','')
     self.m = g.p.connect()
     c.tracks = self.m.search('Genre', c.genre)
     return render('/genre.html')
示例#35
0
文件: main.py 项目: goosemo/theory
    def fullscreen(self):
        """ controller for the fullscreen widget """

        return render('/fullscreen.html')
示例#36
0
文件: main.py 项目: goosemo/theory
 def genres(self):
     c.genres = sorted(g.genres)
     return render('/genres.html')
示例#37
0
文件: main.py 项目: goosemo/theory
 def genre(self):
     c.genre = request.GET.get('genre','')
     m = g.p.connect()
     c.tracks = m.search('Genre', c.genre)
     return render('/genre.html')
示例#38
0
 def genres(self):
     c.genres = sorted(g.genres)
     return render('/genres.html')
示例#39
0
文件: login.py 项目: goosemo/theory
   def login(self):
       """
       Show login form. Submits to /login/submit
       """

       return render('/login.html')