Icon server app updates
@@ -1,10 +1,8 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from __future__ import absolute_import
|
||||
|
||||
from app_registry.models import App
|
||||
#from django.utils.translation import ugettext_lazy as _
|
||||
#from django.conf import settings
|
||||
|
||||
try:
|
||||
app = App.register('icons', _(u'Icons'))
|
||||
except App.UnableToRegister:
|
||||
pass
|
||||
else:
|
||||
app.set_dependencies(['app_registry'])
|
||||
from .classes import Icon
|
||||
#from storage.backends.filebasedstorage import FileBasedStorage
|
||||
#afrom app_registry.models import App
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .conf import settings
|
||||
from .sets import ICON_THEMES
|
||||
from .literals import ERROR
|
||||
|
||||
|
||||
def get_icon_name(icon):
|
||||
try:
|
||||
return ICON_THEMES[settings.ICON_SET][icon]
|
||||
except KeyError:
|
||||
return ICON_THEMES[settings.ICON_SET][ERROR]
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def get_sprite_name(sprite):
|
||||
try:
|
||||
return ICON_THEMES[settings.ICON_SET][sprite]
|
||||
except KeyError:
|
||||
return ICON_THEMES[settings.ICON_SET][ERROR]
|
||||
except AttributeError:
|
||||
pass
|
||||
38
apps/icons/classes.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.conf import settings
|
||||
|
||||
from .settings import ICON_SET
|
||||
from .sets import ICON_THEMES
|
||||
from .literals import ERROR
|
||||
|
||||
SIZE_SMALL = '16x16'
|
||||
SIZE_BIG = '32x32'
|
||||
|
||||
|
||||
class Icon(object):
|
||||
_registry = {}
|
||||
|
||||
def __init__(self, literal):
|
||||
self.literal = literal
|
||||
self.__class__._registry[literal] = self
|
||||
|
||||
def get_file_name(self, size):
|
||||
# TODO: Move name + size resolution to sets to support size/name and
|
||||
# name_size filename conventions
|
||||
try:
|
||||
return '%s/%s/%s' % (ICON_THEMES[ICON_SET].path, size, ICON_THEMES[ICON_SET].dictionary[self.literal])
|
||||
except KeyError:
|
||||
return '%s/%s/%s' % (ICON_THEMES[ICON_SET].path, size, ICON_THEMES[ICON_SET].dictionary[ERROR])
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def display(self, size): # TODO: move to widgets?
|
||||
return mark_safe(u'<img src="%sicons/%s" />' % (settings.STATIC_URL, self.get_file_name(self.literal)))
|
||||
|
||||
def display_small(self):
|
||||
return self.display(SIZE_SMALL)
|
||||
|
||||
def display_big(self):
|
||||
return self.display(SIZE_BIG)
|
||||
@@ -1,24 +0,0 @@
|
||||
"""
|
||||
Configuration options for the documents app
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings
|
||||
|
||||
from storage.backends.filebasedstorage import FileBasedStorage
|
||||
from smart_settings.api import Setting, SettingNamespace
|
||||
from ..literals import DEFAULT_ICON_SET
|
||||
|
||||
from .. import app
|
||||
print '__file__', __file__
|
||||
namespace = SettingNamespace(app.name, app.label, module='icons.conf.settings', sprite='page')
|
||||
|
||||
# Saving
|
||||
|
||||
Setting(
|
||||
namespace=namespace,
|
||||
name='ICON_SET',
|
||||
global_name='ICONS_ICON_SET',
|
||||
default=DEFAULT_ICON_SET,
|
||||
)
|
||||
@@ -3,8 +3,27 @@
|
||||
#DEFAULT_ICON_SET = fat_cow.ID
|
||||
DEFAULT_ICON_SET = 'fat_cow'
|
||||
|
||||
APP = 'app'
|
||||
BACKUPS = 'backups'
|
||||
#APP = 'app'
|
||||
#BACKUPS = 'backups'
|
||||
#ERROR = 'error'
|
||||
#ICONS = 'icons'
|
||||
#SETTINGS = 'settings'
|
||||
|
||||
APPLICATION_VIEW_ICONS = 'application_view_icons'
|
||||
CD_BURN = 'cd_burn'
|
||||
COG = 'cog'
|
||||
ERROR = 'error'
|
||||
ICONS = 'icons'
|
||||
GROUP = 'user',
|
||||
GROUP_ADD = 'user_add'
|
||||
GROUP_EDIT = 'user_edit'
|
||||
GROUP_DELETE = 'user_delete'
|
||||
LOCK = 'lock'
|
||||
MEDAL_GOLD = 'medal_gold'
|
||||
MEDAL_GOLD_ADD = 'medal_gold_add'
|
||||
MEDAL_GOLD_DELETE = 'medal_gold_delete'
|
||||
PLUGIN = 'plugin'
|
||||
USER = 'user'
|
||||
USER_ADD = 'user_add'
|
||||
USER_EDIT = 'user_edit'
|
||||
USER_DELETE = 'user_delete'
|
||||
|
||||
|
||||
5
apps/icons/registry.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
name = 'icons'
|
||||
label = _(u'Icons')
|
||||
#app.set_dependencies(['app_registry'])
|
||||
@@ -11,8 +11,8 @@ SET_CHOICES = (
|
||||
)
|
||||
|
||||
ICON_THEMES = {
|
||||
fat_cow.ID: fat_cow.DICTIONARY,
|
||||
famfamfam.ID: famfamfam.DICTIONARY
|
||||
fat_cow.ID: fat_cow,
|
||||
famfamfam.ID: famfamfam,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@ ID = 'famfamfam'
|
||||
LABEL = _(u'FamFamFam')
|
||||
|
||||
DICTIONARY = {
|
||||
APP: 'plugin',
|
||||
BACKUPS: 'cd_burn',
|
||||
PLUGIN: 'plugin',
|
||||
CD_BURN: 'cd_burn',
|
||||
}
|
||||
|
||||
@@ -4,13 +4,21 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from icons.literals import *
|
||||
|
||||
PATH = os.path.join('Fat Cow', '32x32')
|
||||
PATH = os.path.join('fat_cow')
|
||||
ID = 'fat_cow'
|
||||
LABEL = _(u'Fat cow')
|
||||
|
||||
DICTIONARY = {
|
||||
APP: 'plugin.png',
|
||||
BACKUPS: 'cd_burn.png',
|
||||
APPLICATION_VIEW_ICONS: 'application_view_icons.png',
|
||||
CD_BURN: 'cd_burn.png',
|
||||
COG: 'cog.png',
|
||||
ERROR: 'error.png',
|
||||
ICONS: 'application_view_icons.png',
|
||||
GROUP: 'group.png',
|
||||
GROUP_ADD: 'group_add.png',
|
||||
GROUP_EDIT: 'group_edit.png',
|
||||
GROUP_DELETE: 'group_delete.png',
|
||||
MEDAL_GOLD: 'medal_gold_1.png',
|
||||
MEDAL_GOLD_ADD: 'medal_gold_add.png',
|
||||
MEDAL_GOLD_DELETE: 'medal_gold_delete.png',
|
||||
PLUGIN: 'plugin.png',
|
||||
}
|
||||
|
||||
13
apps/icons/settings.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .literals import DEFAULT_ICON_SET
|
||||
|
||||
|
||||
#
|
||||
# #print '__file__', __file__
|
||||
# ICON_SET = app.add_setting(
|
||||
# name='ICON_SET',
|
||||
# default=literals.DEFAULT_ICON_SET,
|
||||
# )
|
||||
|
||||
ICON_SET = DEFAULT_ICON_SET
|
||||
|
Before Width: | Height: | Size: 825 B After Width: | Height: | Size: 825 B |
|
Before Width: | Height: | Size: 445 B After Width: | Height: | Size: 445 B |
|
Before Width: | Height: | Size: 838 B After Width: | Height: | Size: 838 B |
|
Before Width: | Height: | Size: 686 B After Width: | Height: | Size: 686 B |
|
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 712 B |
|
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 450 B |
|
Before Width: | Height: | Size: 885 B After Width: | Height: | Size: 885 B |
|
Before Width: | Height: | Size: 674 B After Width: | Height: | Size: 674 B |
|
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 670 B |
|
Before Width: | Height: | Size: 698 B After Width: | Height: | Size: 698 B |
|
Before Width: | Height: | Size: 685 B After Width: | Height: | Size: 685 B |
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
|
Before Width: | Height: | Size: 659 B After Width: | Height: | Size: 659 B |
|
Before Width: | Height: | Size: 722 B After Width: | Height: | Size: 722 B |
|
Before Width: | Height: | Size: 775 B After Width: | Height: | Size: 775 B |
|
Before Width: | Height: | Size: 737 B After Width: | Height: | Size: 737 B |
|
Before Width: | Height: | Size: 437 B After Width: | Height: | Size: 437 B |
|
Before Width: | Height: | Size: 433 B After Width: | Height: | Size: 433 B |
|
Before Width: | Height: | Size: 531 B After Width: | Height: | Size: 531 B |
|
Before Width: | Height: | Size: 481 B After Width: | Height: | Size: 481 B |
|
Before Width: | Height: | Size: 532 B After Width: | Height: | Size: 532 B |
|
Before Width: | Height: | Size: 452 B After Width: | Height: | Size: 452 B |
|
Before Width: | Height: | Size: 563 B After Width: | Height: | Size: 563 B |
|
Before Width: | Height: | Size: 532 B After Width: | Height: | Size: 532 B |
|
Before Width: | Height: | Size: 809 B After Width: | Height: | Size: 809 B |
|
Before Width: | Height: | Size: 605 B After Width: | Height: | Size: 605 B |
|
Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 525 B |
|
Before Width: | Height: | Size: 831 B After Width: | Height: | Size: 831 B |
|
Before Width: | Height: | Size: 583 B After Width: | Height: | Size: 583 B |
|
Before Width: | Height: | Size: 714 B After Width: | Height: | Size: 714 B |
|
Before Width: | Height: | Size: 777 B After Width: | Height: | Size: 777 B |
|
Before Width: | Height: | Size: 749 B After Width: | Height: | Size: 749 B |
|
Before Width: | Height: | Size: 716 B After Width: | Height: | Size: 716 B |
|
Before Width: | Height: | Size: 665 B After Width: | Height: | Size: 665 B |
|
Before Width: | Height: | Size: 636 B After Width: | Height: | Size: 636 B |
|
Before Width: | Height: | Size: 661 B After Width: | Height: | Size: 661 B |
|
Before Width: | Height: | Size: 366 B After Width: | Height: | Size: 366 B |
|
Before Width: | Height: | Size: 584 B After Width: | Height: | Size: 584 B |
|
Before Width: | Height: | Size: 535 B After Width: | Height: | Size: 535 B |
|
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 249 B |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
|
Before Width: | Height: | Size: 534 B After Width: | Height: | Size: 534 B |
|
Before Width: | Height: | Size: 671 B After Width: | Height: | Size: 671 B |
|
Before Width: | Height: | Size: 657 B After Width: | Height: | Size: 657 B |
|
Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 525 B |
|
Before Width: | Height: | Size: 688 B After Width: | Height: | Size: 688 B |
|
Before Width: | Height: | Size: 689 B After Width: | Height: | Size: 689 B |
|
Before Width: | Height: | Size: 759 B After Width: | Height: | Size: 759 B |
|
Before Width: | Height: | Size: 713 B After Width: | Height: | Size: 713 B |
|
Before Width: | Height: | Size: 694 B After Width: | Height: | Size: 694 B |
|
Before Width: | Height: | Size: 641 B After Width: | Height: | Size: 641 B |
|
Before Width: | Height: | Size: 664 B After Width: | Height: | Size: 664 B |
|
Before Width: | Height: | Size: 623 B After Width: | Height: | Size: 623 B |
|
Before Width: | Height: | Size: 663 B After Width: | Height: | Size: 663 B |
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
|
Before Width: | Height: | Size: 599 B After Width: | Height: | Size: 599 B |
|
Before Width: | Height: | Size: 468 B After Width: | Height: | Size: 468 B |
|
Before Width: | Height: | Size: 575 B After Width: | Height: | Size: 575 B |
|
Before Width: | Height: | Size: 650 B After Width: | Height: | Size: 650 B |
|
Before Width: | Height: | Size: 483 B After Width: | Height: | Size: 483 B |
|
Before Width: | Height: | Size: 649 B After Width: | Height: | Size: 649 B |
|
Before Width: | Height: | Size: 643 B After Width: | Height: | Size: 643 B |
|
Before Width: | Height: | Size: 538 B After Width: | Height: | Size: 538 B |
|
Before Width: | Height: | Size: 522 B After Width: | Height: | Size: 522 B |
|
Before Width: | Height: | Size: 394 B After Width: | Height: | Size: 394 B |
|
Before Width: | Height: | Size: 422 B After Width: | Height: | Size: 422 B |
|
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 369 B |
|
Before Width: | Height: | Size: 564 B After Width: | Height: | Size: 564 B |
|
Before Width: | Height: | Size: 587 B After Width: | Height: | Size: 587 B |
|
Before Width: | Height: | Size: 628 B After Width: | Height: | Size: 628 B |
|
Before Width: | Height: | Size: 588 B After Width: | Height: | Size: 588 B |
|
Before Width: | Height: | Size: 554 B After Width: | Height: | Size: 554 B |
|
Before Width: | Height: | Size: 603 B After Width: | Height: | Size: 603 B |
|
Before Width: | Height: | Size: 494 B After Width: | Height: | Size: 494 B |
|
Before Width: | Height: | Size: 538 B After Width: | Height: | Size: 538 B |
|
Before Width: | Height: | Size: 598 B After Width: | Height: | Size: 598 B |
|
Before Width: | Height: | Size: 761 B After Width: | Height: | Size: 761 B |
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
|
Before Width: | Height: | Size: 651 B After Width: | Height: | Size: 651 B |
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 381 B |
|
Before Width: | Height: | Size: 593 B After Width: | Height: | Size: 593 B |
|
Before Width: | Height: | Size: 570 B After Width: | Height: | Size: 570 B |
|
Before Width: | Height: | Size: 556 B After Width: | Height: | Size: 556 B |
|
Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B |
|
Before Width: | Height: | Size: 508 B After Width: | Height: | Size: 508 B |