Ejemplo n.º 1
0
 def __init__(self, attrs=None):
     if version_tuple(dojo_config.version) < (1,3):
         self.js_regex_func = 'dojox.regexp.url'
     super(URLTextInput, self).__init__(attrs)
Ejemplo n.º 2
0
 def __init__(self, attrs=None):
     if version_tuple(dojo_config.version) < (1,3):
         self.alt_require = 'dijit.form.Slider'
     super(HorizontalSliderInput, self).__init__(attrs)
Ejemplo n.º 3
0
 def __init__(self, attrs=None):
     if version_tuple(dojo_config.version) < (1,3):
         self.js_regex_func = 'dojox.regexp.emailAddress'
     super(EmailTextInput, self).__init__(attrs)
Ejemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     if version_tuple(dojo_config.version) < (1,3):
         self.alt_require = 'dijit.form.CheckBox'
     super(RadioSelect, self).__init__(*args, **kwargs)
Ejemplo n.º 5
0
 def handle(self, *args, **options):
     if len(args)==0:
         # with no param, we use the default profile, that is defined in the settings
         profile_name = settings.DOJO_BUILD_PROFILE
     else:
         profile_name = args[0]
     profile = self._get_profile(profile_name)
     used_src_version = profile['used_src_version'] % {'DOJO_BUILD_VERSION': settings.DOJO_BUILD_VERSION} # no dependencies to project's settings.py file!
     # used by minify_extreme!
     self.skip_files = profile.get("minify_extreme_skip_files", ())
     self.dojo_base_dir = "%(dojo_root)s/%(version)s" % \
                          {'dojo_root':settings.BASE_DOJO_ROOT, 
                          'version':used_src_version}
     # does the defined dojo-directory exist?
     util_base_dir = "%(dojo_base_dir)s/util" % {'dojo_base_dir':self.dojo_base_dir}
     if not os.path.exists(util_base_dir):
         raise CommandError('Put the the dojo source files (version \'%(version)s\') in the folder \'%(folder)s/%(version)s\' or set a different version in settings.DOJANGO_DOJO_BUILD_VERSION' % \
                            {'version':used_src_version,
                             'folder':settings.BASE_DOJO_ROOT})
     # check, if java is installed
     try:
         # ignoring output of the java call
         subprocess.call(settings.DOJO_BUILD_JAVA_EXEC, stdout=subprocess.PIPE) # will work with python >= 2.4
     except:
         raise CommandError('Please install java. You need it for building dojo.')
     buildscript_dir = os.path.abspath('%s/buildscripts' % util_base_dir)
     if version_tuple(settings.DOJO_BUILD_USED_VERSION) < (1,2,0):
         executable = '%(java_exec)s -jar ../shrinksafe/custom_rhino.jar build.js' % \
                      {'java_exec':settings.DOJO_BUILD_JAVA_EXEC}
     else:
         # use the new build command line call!
         if(os.path.sep == "\\"):
             executable = 'build.bat'
         else:
             executable = './build.sh'
             # force executable rights!
             os.chmod(os.path.join(buildscript_dir, 'build.sh'), 0755)
     # use the passed version for building
     version = options.get('build_version', None)
     if not version:
         # if no option --build_version was passed, we use the default build version
         version = profile['build_version'] % {'DOJO_BUILD_VERSION': settings.DOJO_BUILD_VERSION} # no dependencies to project's settings.py file!
     # we add the version to our destination base path
     self.dojo_release_dir = '%(base_path)s/%(version)s' % {
                       'base_path':profile['base_root'] % {'BASE_MEDIA_ROOT':settings.BASE_MEDIA_ROOT},
                       'version':version} # we don't want to have a dependancy to the project's settings file!
     release_dir = os.path.abspath(os.path.join(self.dojo_release_dir, "../"))
     # the build command handling is so different between the versions!
     # sometimes we need to add /, sometimes not :-(
     if version_tuple(settings.DOJO_BUILD_USED_VERSION) < (1,2,0):
         release_dir = release_dir + os.path.sep
     # setting up the build command
     build_addons = ""
     if version_tuple(settings.DOJO_BUILD_USED_VERSION) >= (1,2,0):
         # since version 1.2.0 there is an additional commandline option that does the mini build (solved within js!)
         build_addons = "mini=true"
     exe_command = 'cd "%(buildscript_dir)s" && %(executable)s version=%(version)s releaseName="%(version)s" releaseDir="%(release_dir)s" %(options)s %(build_addons)s' % \
                   {'buildscript_dir':buildscript_dir,
                    'executable':executable,
                    'version':version,
                    'release_dir':release_dir,
                    'options':profile['options'] % {'BASE_MEDIA_ROOT':settings.BASE_MEDIA_ROOT},
                    'build_addons':build_addons}
     # print exe_command
     minify = options['minify']
     minify_extreme = options['minify_extreme']
     prepare_zipserve = options['prepare_zipserve']
     if (version_tuple(settings.DOJO_BUILD_USED_VERSION) < (1,2,0)) and (minify or minify_extreme):
         self._dojo_mini_before_build()
     if sys.platform == 'win32': # fixing issue #39, if dojango is installed on a different drive
         exe_command = os.path.splitdrive(buildscript_dir)[0] + ' && ' + exe_command
     
     # do the build
     exit_code = os.system(exe_command)
     if exit_code: # != 0
         sys.exit(1) # dojobuild exits because of shrinksafe error
     if version_tuple(settings.DOJO_BUILD_USED_VERSION) < (1,2,0):
         if minify or minify_extreme:
             self._dojo_mini_after_build()
     if minify_extreme:
         self._dojo_mini_extreme()
     if prepare_zipserve:
         self._dojo_prepare_zipserve()
Ejemplo n.º 6
0
# "./manage.py dojobuild dojango" would have the same effect
DOJO_BUILD_PROFILE = getattr(settings, "DOJANGO_DOJO_BUILD_PROFILE", "dojango")
# This dictionary defines your build profiles you can use within the custom command "./manage.py dojobuild
# You can set your own build profile within the main settings.py of the project by defining a dictionary
# DOJANGO_DOJO_BUILD_PROFILES, that sets the following key/value pairs for each defined profile name:
#   profile_file: which dojo profile file is used for the build (see dojango.profile.js how it has to look)
#   options: these are the options that are passed to the build command (see the dojo doc for details)
#   OPTIONAL SETTINGS (see DOJO_BUILD_PROFILES_DEFAULT):
#   base_root: in which directory will the dojo version be builded to? 
#   used_src_version: which version should be used for the dojo build (e.g. 1.1.1)
#   build_version: what is the version name of the builded release (e.g. dojango1.1.1) - this option can be overwritten by the commandline parameter --build_version=...
#   minify_extreme_skip_files: a tupel of files/folders (each expressed as regular expression) that should be kept when doing a minify extreme (useful when you have several layers and don't want some files)
#                              this tupel will be appended to the default folders/files that are skipped: see SKIP_FILES in management/commands/dojobuild.py 
DOJO_BUILD_PROFILES = {
    'dojango': {
        'options': (version_tuple(DOJO_VERSION) > (1,6) and 'profile' or 'profileFile') + '="%(BASE_MEDIA_ROOT)s/dojango.profile.js" action=release optimize=shrinksafe.keepLines cssOptimize=comments.keepLines',
    },
    'dojango_optimized': {
        'options': (version_tuple(DOJO_VERSION) > (1,6) and 'profile' or 'profileFile') + '="%(BASE_MEDIA_ROOT)s/dojango_optimized.profile.js" action=release optimize=shrinksafe.keepLines cssOptimize=comments.keepLines',
        'build_version': '%(DOJO_BUILD_VERSION)s-dojango-optimized-with-dojo',
    },
}

# these defaults are mixed into each DOJO_BUILD_PROFILES element
# but you can overwrite each attribute within your own build profile element
# e.g. DOJANGO_BUILD_PROFILES = {'used_src_version': '1.2.2', ....}
DOJO_BUILD_PROFILES_DEFAULT = getattr(settings, "DOJANGO_DOJO_BUILD_PROFILES_DEFAULT", {
    # build the release in the media directory of dojango
    # use a formatting string, so this can be set in the project's settings.py without getting the dojango settings
    'base_root': '%(BASE_MEDIA_ROOT)s/release',
    'used_src_version': '%(DOJO_BUILD_VERSION)s',
Ejemplo n.º 7
0
# "./manage.py dojobuild dojango" would have the same effect
DOJO_BUILD_PROFILE = getattr(settings, "DOJANGO_DOJO_BUILD_PROFILE", "dojango")
# This dictionary defines your build profiles you can use within the custom command "./manage.py dojobuild
# You can set your own build profile within the main settings.py of the project by defining a dictionary
# DOJANGO_DOJO_BUILD_PROFILES, that sets the following key/value pairs for each defined profile name:
#   profile_file: which dojo profile file is used for the build (see dojango.profile.js how it has to look)
#   options: these are the options that are passed to the build command (see the dojo doc for details)
#   OPTIONAL SETTINGS (see DOJO_BUILD_PROFILES_DEFAULT):
#   base_root: in which directory will the dojo version be builded to?
#   used_src_version: which version should be used for the dojo build (e.g. 1.1.1)
#   build_version: what is the version name of the builded release (e.g. dojango1.1.1) - this option can be overwritten by the commandline parameter --build_version=...
#   minify_extreme_skip_files: a tupel of files/folders (each expressed as regular expression) that should be kept when doing a minify extreme (useful when you have several layers and don't want some files)
#                              this tupel will be appended to the default folders/files that are skipped: see SKIP_FILES in management/commands/dojobuild.py
DOJO_BUILD_PROFILES = {
    "dojango": {
        "options": (version_tuple(DOJO_VERSION) > (1, 6) and "profile" or "profileFile")
        + '="%(BASE_MEDIA_ROOT)s/dojango.profile.js" action=release optimize=shrinksafe.keepLines cssOptimize=comments.keepLines'
    },
    "dojango_optimized": {
        "options": (version_tuple(DOJO_VERSION) > (1, 6) and "profile" or "profileFile")
        + '="%(BASE_MEDIA_ROOT)s/dojango_optimized.profile.js" action=release optimize=shrinksafe.keepLines cssOptimize=comments.keepLines',
        "build_version": "%(DOJO_BUILD_VERSION)s-dojango-optimized-with-dojo",
    },
}

# these defaults are mixed into each DOJO_BUILD_PROFILES element
# but you can overwrite each attribute within your own build profile element
# e.g. DOJANGO_BUILD_PROFILES = {'used_src_version': '1.2.2', ....}
DOJO_BUILD_PROFILES_DEFAULT = getattr(
    settings,
    "DOJANGO_DOJO_BUILD_PROFILES_DEFAULT",
Ejemplo n.º 8
0
    def handle(self, *args, **options):
        if len(args) == 0:
            # with no param, we use the default profile, that is defined in the settings
            profile_name = settings.DOJO_BUILD_PROFILE
        else:
            profile_name = args[0]
        profile = self._get_profile(profile_name)
        used_src_version = profile['used_src_version'] % {
            'DOJO_BUILD_VERSION': settings.DOJO_BUILD_VERSION
        }  # no dependencies to project's settings.py file!
        # used by minify_extreme!
        self.skip_files = profile.get("minify_extreme_skip_files", ())
        self.dojo_base_dir = "%(dojo_root)s/%(version)s" % \
                             {'dojo_root':settings.BASE_DOJO_ROOT,
                             'version':used_src_version}
        # does the defined dojo-directory exist?
        util_base_dir = "%(dojo_base_dir)s/util" % {
            'dojo_base_dir': self.dojo_base_dir
        }
        if not os.path.exists(util_base_dir):
            raise CommandError('Put the the dojo source files (version \'%(version)s\') in the folder \'%(folder)s/%(version)s\' or set a different version in settings.DOJANGO_DOJO_BUILD_VERSION' % \
                               {'version':used_src_version,
                                'folder':settings.BASE_DOJO_ROOT})
        # check, if java is installed
        try:
            # ignoring output of the java call
            subprocess.call(
                settings.DOJO_BUILD_JAVA_EXEC,
                stdout=subprocess.PIPE)  # will work with python >= 2.4
        except:
            raise CommandError(
                'Please install java. You need it for building dojo.')
        buildscript_dir = os.path.abspath('%s/buildscripts' % util_base_dir)
        if version_tuple(settings.DOJO_BUILD_USED_VERSION) < (1, 2, 0):
            executable = '%(java_exec)s -jar ../shrinksafe/custom_rhino.jar build.js' % \
                         {'java_exec':settings.DOJO_BUILD_JAVA_EXEC}
        else:
            # use the new build command line call!
            if (os.path.sep == "\\"):
                executable = 'build.bat'
            else:
                executable = './build.sh'
                # force executable rights!
                os.chmod(os.path.join(buildscript_dir, 'build.sh'), 0755)
        # use the passed version for building
        version = options.get('build_version', None)
        if not version:
            # if no option --build_version was passed, we use the default build version
            version = profile['build_version'] % {
                'DOJO_BUILD_VERSION': settings.DOJO_BUILD_VERSION
            }  # no dependencies to project's settings.py file!
        # we add the version to our destination base path
        self.dojo_release_dir = '%(base_path)s/%(version)s' % {
            'base_path': profile['base_root'] % {
                'BASE_MEDIA_ROOT': settings.BASE_MEDIA_ROOT
            },
            'version': version
        }  # we don't want to have a dependancy to the project's settings file!
        release_dir = os.path.abspath(
            os.path.join(self.dojo_release_dir, "../"))
        # the build command handling is so different between the versions!
        # sometimes we need to add /, sometimes not :-(
        if version_tuple(settings.DOJO_BUILD_USED_VERSION) < (1, 2, 0):
            release_dir = release_dir + os.path.sep
        # setting up the build command
        build_addons = ""
        if version_tuple(settings.DOJO_BUILD_USED_VERSION) >= (1, 2, 0):
            # since version 1.2.0 there is an additional commandline option that does the mini build (solved within js!)
            build_addons = "mini=true"
        exe_command = 'cd "%(buildscript_dir)s" && %(executable)s version=%(version)s releaseName="%(version)s" releaseDir="%(release_dir)s" %(options)s %(build_addons)s' % \
                      {'buildscript_dir':buildscript_dir,
                       'executable':executable,
                       'version':version,
                       'release_dir':release_dir,
                       'options':profile['options'] % {'BASE_MEDIA_ROOT':settings.BASE_MEDIA_ROOT},
                       'build_addons':build_addons}
        # print exe_command
        minify = options['minify']
        minify_extreme = options['minify_extreme']
        prepare_zipserve = options['prepare_zipserve']
        if (version_tuple(settings.DOJO_BUILD_USED_VERSION) <
            (1, 2, 0)) and (minify or minify_extreme):
            self._dojo_mini_before_build()
        if sys.platform == 'win32':  # fixing issue #39, if dojango is installed on a different drive
            exe_command = os.path.splitdrive(
                buildscript_dir)[0] + ' && ' + exe_command

        # do the build
        exit_code = os.system(exe_command)
        if exit_code:  # != 0
            sys.exit(1)  # dojobuild exits because of shrinksafe error
        if version_tuple(settings.DOJO_BUILD_USED_VERSION) < (1, 2, 0):
            if minify or minify_extreme:
                self._dojo_mini_after_build()
        if minify_extreme:
            self._dojo_mini_extreme()
        if prepare_zipserve:
            self._dojo_prepare_zipserve()