def index(request): tiles = [] for api in plugin_api_modules: if hasattr(api, 'tiles'): tiles.extend(api.tiles()) tiles.sort() tiles = [mark_safe(tile) for _, tile in tiles] rows = chunks(tiles, 3) return render(request, 'index.html', {'rows': rows})
def browse(request): path = request.GET.get('path', expanduser('~/Downloads')) objects = ['..'] + [x for x in sorted(listdir(path)) if not x.startswith('.')] objects = [ListItem('/browse/?path=%s/%s' % (path, o), o) for o in objects] title = path.split('/')[-1] if not title: title = path.split('/')[-2] columns = [x for x in chunks(objects, 10, pad=True)] rows = zip(*columns) return render(request, 'list.html', {'rows': rows, 'title': title})
def browse(request): path = request.GET.get('path', expanduser('~/Downloads')) objects = ['..' ] + [x for x in sorted(listdir(path)) if not x.startswith('.')] objects = [ListItem('/browse/?path=%s/%s' % (path, o), o) for o in objects] title = path.split('/')[-1] if not title: title = path.split('/')[-2] columns = [x for x in chunks(objects, 10, pad=True)] rows = zip(*columns) return render(request, 'list.html', {'rows': rows, 'title': title})
def index(request): shows = sorted(Show.objects.all(), key=lambda x: title_sort_key(x.name)) shows = [ListItem('/tvshows/%s' % show.pk, show.name, show.unwatched_episodes().count()) for show in shows if show.unwatched_episodes()] rows = chunks(shows, 2) return render(request, 'list.html', {'title': 'TV Shows', 'rows': rows})