Exemplo n.º 1
0
def application_settings(request):
    """The context processor function"""
    if not request.path.startswith('/' + settings.ASKBOT_URL):
        #todo: this is a really ugly hack, will only work
        #when askbot is installed not at the home page.
        #this will not work for the
        #heavy modders of askbot, because their custom pages
        #will not receive the askbot settings in the context
        #to solve this properly we should probably explicitly
        #add settings to the context per page
        return {}
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['STATIC_URL'] = settings.STATIC_URL
    my_settings['ASKBOT_CSS_DEVEL'] = getattr(settings, 'ASKBOT_CSS_DEVEL', False)
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['USING_RUNSERVER'] = 'runserver' in sys.argv
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    my_settings['LOGIN_URL'] = url_utils.get_login_url()
    my_settings['LOGOUT_URL'] = url_utils.get_logout_url()
    my_settings['LOGOUT_REDIRECT_URL'] = url_utils.get_logout_redirect_url()
    my_settings['USE_ASKBOT_LOGIN_SYSTEM'] = 'askbot.deps.django_authopenid' \
        in settings.INSTALLED_APPS
    return {
        'settings': my_settings,
        'skin': get_skin(request),
        'moderation_items': api.get_info_on_moderation_items(request.user),
        'noscript_url': const.DEPENDENCY_URLS['noscript'],
    }
Exemplo n.º 2
0
        def wrapper(request, *args, **kwargs):

            if askbot_settings.USE_AKISMET and askbot_settings.AKISMET_API_KEY == "":
                raise ImproperlyConfigured('You have not set AKISMET_API_KEY')

            if askbot_settings.USE_AKISMET and request.method == "POST":
                comment = smart_str(request.POST[field])
                data = {'user_ip': request.META.get('REMOTE_ADDR'),
                        'user_agent': request.environ['HTTP_USER_AGENT'],
                        'comment_author': smart_str(request.user.username),
                        }
                if request.user.is_authenticated():
                    data.update({'comment_author_email': request.user.email})

                from akismet import Akismet
                api = Akismet(
                    askbot_settings.AKISMET_API_KEY,
                    smart_str(site_url(reverse('questions'))),
                    "Askbot/%s" % get_version()
                )

                if api.comment_check(comment, data, build_data=False):
                    logging.debug('Spam detected in %s post at: %s', request.user.username, timezone.now())
                    spam_message = _(
                        'Spam was detected on your post, sorry '
                        'for if this is a mistake'
                    )
                    if request.is_ajax():
                        return HttpResponseForbidden(spam_message, mimetype="application/json")
                    else:
                        # request.user.message_set.create(message=spam_message)
                        django_messages.info(request, spam_message)
                        return redirect('index')

            return view_func(request, *args, **kwargs)
Exemplo n.º 3
0
def application_settings(request):
    """The context processor function"""
    if not request.path.startswith("/" + settings.ASKBOT_URL):
        # todo: this is a really ugly hack, will only work
        # when askbot is installed not at the home page.
        # this will not work for the
        # heavy modders of askbot, because their custom pages
        # will not receive the askbot settings in the context
        # to solve this properly we should probably explicitly
        # add settings to the context per page
        return {}
    my_settings = askbot_settings.as_dict()
    my_settings["LANGUAGE_CODE"] = getattr(request, "LANGUAGE_CODE", settings.LANGUAGE_CODE)
    my_settings["ASKBOT_URL"] = settings.ASKBOT_URL
    my_settings["STATIC_URL"] = settings.STATIC_URL
    my_settings["ASKBOT_CSS_DEVEL"] = getattr(settings, "ASKBOT_CSS_DEVEL", False)
    my_settings["USE_LOCAL_FONTS"] = getattr(settings, "ASKBOT_USE_LOCAL_FONTS", False)
    my_settings["DEBUG"] = settings.DEBUG
    my_settings["USING_RUNSERVER"] = "runserver" in sys.argv
    my_settings["ASKBOT_VERSION"] = askbot.get_version()
    my_settings["LOGIN_URL"] = url_utils.get_login_url()
    my_settings["LOGOUT_URL"] = url_utils.get_logout_url()
    my_settings["LOGOUT_REDIRECT_URL"] = url_utils.get_logout_redirect_url()
    my_settings["USE_ASKBOT_LOGIN_SYSTEM"] = "askbot.deps.django_authopenid" in settings.INSTALLED_APPS
    return {
        "settings": my_settings,
        "skin": get_skin(request),
        "moderation_items": api.get_info_on_moderation_items(request.user),
        "noscript_url": const.DEPENDENCY_URLS["noscript"],
    }
Exemplo n.º 4
0
def akismet_check_spam(text, request):
    """Returns True if spam found, false if not,
    May raise exceptions if something is not right with
    the Akismet account/service/setup"""
    if not askbot_settings.USE_AKISMET:
        return False
    try:
        if askbot_settings.USE_AKISMET and askbot_settings.AKISMET_API_KEY == "":
            raise ImproperlyConfigured('You have not set AKISMET_API_KEY')
        data = {'user_ip': request.META.get('REMOTE_ADDR'),
                'user_agent': request.environ['HTTP_USER_AGENT'],
                'comment_author': smart_str(request.user.username)
                }
        if request.user.is_authenticated():
            data.update({'comment_author_email': request.user.email})

        api = Akismet(
            askbot_settings.AKISMET_API_KEY,
            smart_str(site_url(reverse('questions'))),
            "Askbot/%s" % get_version()
        )
        return api.comment_check(text, data, build_data=False)
    except APIKeyError:
        logging.critical('Akismet Key is missing')
    except AkismetError:
        logging.critical('Akismet error: Invalid Akismet key or Akismet account issue!')
    except Exception as e:
        logging.critical((u'Akismet error: %s' % unicode(e)).encode('utf-8'))
    return False
Exemplo n.º 5
0
        def wrapper(request, *args, **kwargs):

            if askbot_settings.USE_AKISMET and askbot_settings.AKISMET_API_KEY == "":
                raise ImproperlyConfigured('You have not set AKISMET_API_KEY')

            if askbot_settings.USE_AKISMET and request.method == "POST":
                comment = smart_str(request.POST[field])
                data = {
                    'user_ip': request.META.get('REMOTE_ADDR'),
                    'user_agent': request.environ['HTTP_USER_AGENT'],
                    'comment_author': smart_str(request.user.username),
                }
                if request.user.is_authenticated():
                    data.update({'comment_author_email': request.user.email})

                from akismet import Akismet
                api = Akismet(askbot_settings.AKISMET_API_KEY,
                              smart_str(site_url(reverse('questions'))),
                              "Askbot/%s" % get_version())

                if api.comment_check(comment, data, build_data=False):
                    logging.debug('Spam detected in %s post at: %s',
                                  request.user.username,
                                  datetime.datetime.now())
                    spam_message = _('Spam was detected on your post, sorry '
                                     'for if this is a mistake')
                    if request.is_ajax():
                        return HttpResponseForbidden(
                            spam_message, mimetype="application/json")
                    else:
                        request.user.message_set.create(message=spam_message)
                        return HttpResponseRedirect(reverse('index'))

            return view_func(request, *args, **kwargs)
Exemplo n.º 6
0
def akismet_check_spam(text, request):
    """Returns True if spam found, false if not,
    May raise exceptions if something is not right with
    the Akismet account/service/setup"""
    try:
        if askbot_settings.USE_AKISMET and askbot_settings.AKISMET_API_KEY == "":
            raise ImproperlyConfigured('You have not set AKISMET_API_KEY')
        data = {'user_ip': request.META.get('REMOTE_ADDR'),
                'user_agent': request.environ['HTTP_USER_AGENT'],
                'comment_author': smart_str(request.user.username)
                }
        if request.user.is_authenticated():
            data.update({'comment_author_email': request.user.email})

        api = Akismet(
            askbot_settings.AKISMET_API_KEY,
            smart_str(site_url(reverse('questions'))),
            "Askbot/%s" % get_version()
        )
        return api.comment_check(text, data, build_data=False)
    except APIKeyError:
        logging.critical('Akismet Key is missing')
    except AkismetError:
        logging.critical('Akismet error: Invalid Akismet key or Akismet account issue!')
    except Exception, e:
        logging.critical((u'Akismet error: %s' % unicode(e)).encode('utf-8'))
Exemplo n.º 7
0
def application_settings(request):
    """The context processor function"""
    if not request.path.startswith('/' + settings.ASKBOT_URL):
        #todo: this is a really ugly hack, will only work
        #when askbot is installed not at the home page.
        #this will not work for the
        #heavy modders of askbot, because their custom pages
        #will not receive the askbot settings in the context
        #to solve this properly we should probably explicitly
        #add settings to the context per page
        return {}
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE',
                                           settings.LANGUAGE_CODE)
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['STATIC_URL'] = settings.STATIC_URL
    my_settings['ASKBOT_CSS_DEVEL'] = getattr(settings, 'ASKBOT_CSS_DEVEL',
                                              False)
    my_settings['USE_LOCAL_FONTS'] = getattr(settings,
                                             'ASKBOT_USE_LOCAL_FONTS', False)
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['USING_RUNSERVER'] = 'runserver' in sys.argv
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    my_settings['LOGIN_URL'] = url_utils.get_login_url()
    my_settings['LOGOUT_URL'] = url_utils.get_logout_url()
    my_settings['LOGOUT_REDIRECT_URL'] = url_utils.get_logout_redirect_url()
    my_settings['USE_ASKBOT_LOGIN_SYSTEM'] = 'askbot.deps.django_authopenid' \
        in settings.INSTALLED_APPS
    return {
        'settings': my_settings,
        'skin': get_skin(request),
        'moderation_items': api.get_info_on_moderation_items(request.user),
        'noscript_url': const.DEPENDENCY_URLS['noscript'],
    }
Exemplo n.º 8
0
def application_settings(request):
    """The context processor function"""
    if not request.path.startswith('/' + settings.ASKBOT_URL):
        #todo: this is a really ugly hack, will only work
        #when askbot is installed not at the home page.
        #this will not work for the
        #heavy modders of askbot, because their custom pages
        #will not receive the askbot settings in the context
        #to solve this properly we should probably explicitly
        #add settings to the context per page
        return {}
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
    my_settings['ALLOWED_UPLOAD_FILE_TYPES'] = \
            settings.ASKBOT_ALLOWED_UPLOAD_FILE_TYPES
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['STATIC_URL'] = settings.STATIC_URL
    my_settings['ASKBOT_CSS_DEVEL'] = getattr(
                                        settings,
                                        'ASKBOT_CSS_DEVEL',
                                        False
                                    )
    my_settings['USE_LOCAL_FONTS'] = getattr(
                                        settings,
                                        'ASKBOT_USE_LOCAL_FONTS',
                                        False
                                    )
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['USING_RUNSERVER'] = 'runserver' in sys.argv
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    my_settings['LOGIN_URL'] = url_utils.get_login_url()
    my_settings['LOGOUT_URL'] = url_utils.get_logout_url()
    my_settings['LOGOUT_REDIRECT_URL'] = url_utils.get_logout_redirect_url()
    my_settings['USE_ASKBOT_LOGIN_SYSTEM'] = 'askbot.deps.django_authopenid' \
        in settings.INSTALLED_APPS
    context = {
        'settings': my_settings,
        'skin': get_skin(request),
        'moderation_items': api.get_info_on_moderation_items(request.user),
        'noscript_url': const.DEPENDENCY_URLS['noscript'],
    }

    if askbot_settings.GROUPS_ENABLED:
        groups = models.Group.objects.exclude(
                                              name__startswith='_internal_'
                                             ).values('id', 'name')
        group_list = []
        for group in groups:
            group_slug = slugify(group['name'])
            link = reverse('users_by_group',
                    kwargs={'group_id': group['id'],
                        'group_slug': group_slug})
            group_list.append({'name': group['name'], 'link': link})
        context['group_list'] = simplejson.dumps(group_list)

    return context
Exemplo n.º 9
0
def application_settings(request):
    """The context processor function"""
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = settings.LANGUAGE_CODE
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    return {
        'settings': my_settings,
        'skin': get_skin(request),
        'moderation_items': api.get_info_on_moderation_items(request.user)
    }
Exemplo n.º 10
0
def application_settings(request):
    """The context processor function"""
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = settings.LANGUAGE_CODE
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    return {
        'settings': my_settings,
        'skin': get_skin(request),
        'moderation_items': api.get_info_on_moderation_items(request.user)
    }
Exemplo n.º 11
0
def application_settings(request):
    """The context processor function"""
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = settings.LANGUAGE_CODE
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    my_settings['LOGIN_URL'] = url_utils.get_login_url()
    my_settings['LOGOUT_URL'] = url_utils.get_logout_url()
    my_settings['LOGOUT_REDIRECT_URL'] = url_utils.get_logout_redirect_url()
    return {
        'settings': my_settings,
        'skin': get_skin(request),
        'moderation_items': api.get_info_on_moderation_items(request.user),
        'noscript_url': const.DEPENDENCY_URLS['noscript'],
    }
Exemplo n.º 12
0
def application_settings(request):
    """The context processor function"""
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = settings.LANGUAGE_CODE
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    my_settings['LOGIN_URL'] = url_utils.get_login_url()
    my_settings['LOGOUT_URL'] = url_utils.get_logout_url()
    my_settings['LOGOUT_REDIRECT_URL'] = url_utils.get_logout_redirect_url()
    return {
        'settings': my_settings,
        'skin': get_skin(request),
        'moderation_items': api.get_info_on_moderation_items(request.user),
        'noscript_url': const.DEPENDENCY_URLS['noscript'],
    }
Exemplo n.º 13
0
def application_settings(request):
    """The context processor function"""
    my_settings = askbot_settings.as_dict()
    my_settings["LANGUAGE_CODE"] = getattr(request, "LANGUAGE_CODE", settings.LANGUAGE_CODE)
    my_settings["ASKBOT_URL"] = settings.ASKBOT_URL
    my_settings["ASKBOT_CSS_DEVEL"] = getattr(settings, "ASKBOT_CSS_DEVEL", False)
    my_settings["DEBUG"] = settings.DEBUG
    my_settings["ASKBOT_VERSION"] = askbot.get_version()
    my_settings["LOGIN_URL"] = url_utils.get_login_url()
    my_settings["LOGOUT_URL"] = url_utils.get_logout_url()
    my_settings["LOGOUT_REDIRECT_URL"] = url_utils.get_logout_redirect_url()
    my_settings["USE_ASKBOT_LOGIN_SYSTEM"] = "askbot.deps.django_authopenid" in settings.INSTALLED_APPS
    return {
        "settings": my_settings,
        "skin": get_skin(request),
        "moderation_items": api.get_info_on_moderation_items(request.user),
        "noscript_url": const.DEPENDENCY_URLS["noscript"],
    }
Exemplo n.º 14
0
def application_settings(request):
    """The context processor function"""
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['ASKBOT_TRANSLATE_URL'] = settings.ASKBOT_TRANSLATE_URL
    my_settings['ASKBOT_CSS_DEVEL'] = getattr(settings, 'ASKBOT_CSS_DEVEL', False)
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    my_settings['LOGIN_URL'] = url_utils.get_login_url()
    my_settings['LOGOUT_URL'] = url_utils.get_logout_url()
    my_settings['LOGOUT_REDIRECT_URL'] = url_utils.get_logout_redirect_url()
    my_settings['USE_ASKBOT_LOGIN_SYSTEM'] = 'askbot.deps.django_authopenid' \
        in settings.INSTALLED_APPS
    return {
        'settings': my_settings,
        'skin': get_skin(request),
        'moderation_items': api.get_info_on_moderation_items(request.user),
        'noscript_url': const.DEPENDENCY_URLS['noscript'],
    }
Exemplo n.º 15
0
    'django-celery==2.2.3',
    'djkombu==0.9.2',
]

import askbot

WIN_PLATFORMS = (
    'win32',
    'cygwin',
)
if sys.platform not in WIN_PLATFORMS:
    install_requires.append('mysql-python')

setup(
    name="askbot",
    version=askbot.get_version(),
    description=
    'Question and Answer forum, like StackOverflow, written in python and Django',
    packages=find_packages(),
    author='Evgeny.Fadeev',
    author_email='*****@*****.**',
    license='GPLv3',
    keywords='forum, community, wiki, Q&A',
    entry_points={
        'console_scripts': [
            'startforum = askbot.deployment:startforum',
        ]
    },
    url='http://askbot.org',
    include_package_data=True,
    install_requires=install_requires,
Exemplo n.º 16
0
# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'Askbot'
copyright = u'2011, Askbot Project'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
# The short X.Y version.
from askbot import get_version
version = get_version() 
# The full version, including alpha/beta/rc tags.
release = get_version() 

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Exemplo n.º 17
0
def application_settings(request):
    """The context processor function"""
    if not request.path.startswith('/' + settings.ASKBOT_URL):
        #todo: this is a really ugly hack, will only work
        #when askbot is installed not at the home page.
        #this will not work for the
        #heavy modders of askbot, because their custom pages
        #will not receive the askbot settings in the context
        #to solve this properly we should probably explicitly
        #add settings to the context per page
        return {}
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
    my_settings['MULTILINGUAL'] = getattr(settings, 'ASKBOT_MULTILINGUAL', False)
    my_settings['LANGUAGES_DICT'] = dict(getattr(settings, 'LANGUAGES', []))
    my_settings['ALLOWED_UPLOAD_FILE_TYPES'] = \
            settings.ASKBOT_ALLOWED_UPLOAD_FILE_TYPES
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['STATIC_URL'] = settings.STATIC_URL
    my_settings['IP_MODERATION_ENABLED'] = getattr(settings, 'ASKBOT_IP_MODERATION_ENABLED', False)
    my_settings['ASKBOT_CSS_DEVEL'] = getattr(
                                        settings,
                                        'ASKBOT_CSS_DEVEL',
                                        False
                                    )
    my_settings['USE_LOCAL_FONTS'] = getattr(
                                        settings,
                                        'ASKBOT_USE_LOCAL_FONTS',
                                        False
                                    )
    my_settings['CSRF_COOKIE_NAME'] = settings.CSRF_COOKIE_NAME
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['USING_RUNSERVER'] = 'runserver' in sys.argv
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    my_settings['LOGIN_URL'] = url_utils.get_login_url()
    my_settings['LOGOUT_URL'] = url_utils.get_logout_url()

    if my_settings['EDITOR_TYPE'] == 'tinymce':
        tinymce_plugins = settings.TINYMCE_DEFAULT_CONFIG.get('plugins', '').split(',')
        my_settings['TINYMCE_PLUGINS'] = map(lambda v: v.strip(), tinymce_plugins)
    else:
        my_settings['TINYMCE_PLUGINS'] = [];

    my_settings['LOGOUT_REDIRECT_URL'] = url_utils.get_logout_redirect_url()
    my_settings['USE_ASKBOT_LOGIN_SYSTEM'] = 'askbot.deps.django_authopenid' \
        in settings.INSTALLED_APPS
    
    current_language = get_language()

    #for some languages we will start searching for shorter words
    if current_language == 'ja':
        #we need to open the search box and show info message about
        #the japanese lang search
        min_search_word_length = 1
    else:   
        min_search_word_length = my_settings['MIN_SEARCH_WORD_LENGTH']

    need_scope_links = askbot_settings.ALL_SCOPE_ENABLED or \
                    askbot_settings.UNANSWERED_SCOPE_ENABLED or \
                    (request.user.is_authenticated() and askbot_settings.FOLLOWED_SCOPE_ENABLED)

    context = {
        'base_url': site_url(''),
        'empty_search_state': SearchState.get_empty(),
        'min_search_word_length': min_search_word_length,
        'current_language_code': current_language,
        'settings': my_settings,
        'skin': get_skin(),
        'moderation_items': api.get_info_on_moderation_items(request.user),
        'need_scope_links': need_scope_links,
        'noscript_url': const.DEPENDENCY_URLS['noscript'],
    }

    if askbot_settings.GROUPS_ENABLED:
        #calculate context needed to list all the groups
        def _get_group_url(group):
            """calculates url to the group based on its id and name"""
            group_slug = slugify(group['name'])
            return reverse(
                'users_by_group',
                kwargs={'group_id': group['id'], 'group_slug': group_slug}
            )

        #load id's and names of all groups
        global_group = models.Group.objects.get_global_group()
        groups = models.Group.objects.exclude_personal()
        groups = groups.exclude(id=global_group.id)
        groups_data = list(groups.values('id', 'name'))

        #sort groups_data alphanumerically, but case-insensitive
        groups_data = sorted(
                        groups_data,
                        lambda x, y: cmp(x['name'].lower(), y['name'].lower())
                    )

        #insert data for the global group at the first position
        groups_data.insert(0, {'id': global_group.id, 'name': global_group.name})

        #build group_list for the context
        group_list = list()
        for group in groups_data:
            link = _get_group_url(group)
            group_list.append({'name': group['name'], 'link': link})
        context['group_list'] = simplejson.dumps(group_list)

    return context
Exemplo n.º 18
0
import ez_setup

ez_setup.use_setuptools()
from setuptools import setup, find_packages
import sys

#NOTE: if you want to develop askbot
#you might want to install django-debug-toolbar as well

import askbot

setup(
    name="askbot",
    version=askbot.get_version(),  #remember to manually set this correctly
    description=
    'Question and Answer forum, like StackOverflow, written in python and Django',
    packages=find_packages(),
    author='Evgeny.Fadeev',
    author_email='*****@*****.**',
    license='GPLv3',
    keywords='forum, community, wiki, Q&A',
    entry_points={
        'console_scripts': [
            'askbot-setup = askbot.deployment:askbot_setup',
        ]
    },
    url='http://askbot.org',
    include_package_data=True,
    install_requires=askbot.REQUIREMENTS.values(),
    classifiers=[
        'Development Status :: 4 - Beta',
Exemplo n.º 19
0
    'html5lib',
    'django-keyedcache',
    'django-threaded-multihost',
    'django-robots',
    'unidecode',
]

import askbot

WIN_PLATFORMS = ('win32', 'cygwin',)
if sys.platform not in WIN_PLATFORMS:
    install_requires.append('mysql-python')

setup(
    name = "askbot",
    version = askbot.get_version(),
    description = 'Question and Answer forum, like StackOverflow, written in python and Django',
    packages = find_packages(),
    author = 'Evgeny.Fadeev',
    author_email = '*****@*****.**',
    license = 'GPLv3',
    keywords = 'forum, community, wiki, Q&A',
    entry_points = {
        'console_scripts' : [
            'startforum = askbot.deployment:startforum',
        ]
    },
    url = 'http://askbot.org',
    include_package_data = True,
    install_requires = install_requires,
    classifiers = [
Exemplo n.º 20
0
import ez_setup
ez_setup.use_setuptools()
from setuptools import setup, find_packages
import sys

#NOTE: if you want to develop askbot
#you might want to install django-debug-toolbar as well

import askbot

setup(
    name = "askbot",
    version = "%s-%s" % (askbot.get_version(), "-openmooc"),#remember to manually set this correctly
    description = 'Question and Answer forum, like StackOverflow, written in python and Django',
    packages = find_packages(),
    author = 'Evgeny.Fadeev',
    author_email = '*****@*****.**',
    license = 'GPLv3',
    keywords = 'forum, community, wiki, Q&A',
    entry_points = {
        'console_scripts' : [
            'askbot-setup = askbot.deployment:askbot_setup',
        ]
    },
    url = 'http://askbot.org',
    include_package_data = True,
    install_requires = askbot.REQUIREMENTS.values(),
    classifiers = [
        'Development Status :: 4 - Beta',
        'Environment :: Web Environment',
        'Framework :: Django',
Exemplo n.º 21
0
def akismet_check_spam(text, request):
    """Returns True if spam found, false if not,
    May raise exceptions if something is not right with
    the Akismet account/service/setup"""
    if not askbot_settings.USE_AKISMET:
        return False
    try:
        if askbot_settings.USE_AKISMET and askbot_settings.AKISMET_API_KEY == "":
            raise ImproperlyConfigured("You have not set AKISMET_API_KEY")
        data = {
            "user_ip": request.META.get("REMOTE_ADDR"),
            "user_agent": request.environ["HTTP_USER_AGENT"],
            "comment_author": smart_str(request.user.username),
        }
        if request.user.is_authenticated():
            data.update({"comment_author_email": request.user.email})

        api = Akismet(
            askbot_settings.AKISMET_API_KEY, smart_str(site_url(reverse("questions"))), "Askbot/%s" % get_version()
        )
        return api.comment_check(text, data, build_data=False)
    except APIKeyError:
        logging.critical("Akismet Key is missing")
    except AkismetError:
        logging.critical("Akismet error: Invalid Akismet key or Akismet account issue!")
    except Exception, e:
        logging.critical((u"Akismet error: %s" % unicode(e)).encode("utf-8"))
Exemplo n.º 22
0
def application_settings(request):
    """The context processor function"""
    # if not request.path.startswith('/' + settings.ASKBOT_URL):
    #     #todo: this is a really ugly hack, will only work
    #     #when askbot is installed not at the home page.
    #     #this will not work for the
    #     #heavy modders of askbot, because their custom pages
    #     #will not receive the askbot settings in the context
    #     #to solve this properly we should probably explicitly
    #     #add settings to the context per page
    #     return {}
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE',
                                           settings.LANGUAGE_CODE)
    my_settings['LANGUAGE_MODE'] = askbot.get_lang_mode()
    my_settings['MULTILINGUAL'] = askbot.is_multilingual()
    my_settings['LANGUAGES_DICT'] = dict(getattr(settings, 'LANGUAGES', []))
    my_settings[
        'ALLOWED_UPLOAD_FILE_TYPES'] = settings.ASKBOT_ALLOWED_UPLOAD_FILE_TYPES
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['STATIC_URL'] = settings.STATIC_URL
    my_settings['IP_MODERATION_ENABLED'] = getattr(
        settings, 'ASKBOT_IP_MODERATION_ENABLED', False)
    my_settings['USE_LOCAL_FONTS'] = getattr(settings,
                                             'ASKBOT_USE_LOCAL_FONTS', False)
    my_settings['CSRF_COOKIE_NAME'] = settings.CSRF_COOKIE_NAME
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['USING_RUNSERVER'] = 'runserver' in sys.argv
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    my_settings['LOGIN_URL'] = url_utils.get_login_url()
    my_settings['LOGOUT_URL'] = url_utils.get_logout_url()

    if my_settings['EDITOR_TYPE'] == 'tinymce':
        tinymce_plugins = settings.TINYMCE_DEFAULT_CONFIG.get('plugins',
                                                              '').split(',')
        my_settings['TINYMCE_PLUGINS'] = [v.strip() for v in tinymce_plugins]
        my_settings[
            'TINYMCE_EDITOR_DESELECTOR'] = settings.TINYMCE_DEFAULT_CONFIG[
                'editor_deselector']
        my_settings['TINYMCE_CONFIG_JSON'] = json.dumps(
            settings.TINYMCE_DEFAULT_CONFIG)
    else:
        my_settings['TINYMCE_PLUGINS'] = []
        my_settings['TINYMCE_EDITOR_DESELECTOR'] = ''

    my_settings['LOGOUT_REDIRECT_URL'] = url_utils.get_logout_redirect_url()

    current_language = get_language()

    # for some languages we will start searching for shorter words
    if current_language == 'ja':
        # we need to open the search box and show info message about
        # the japanese lang search
        min_search_word_length = 1
    else:
        min_search_word_length = my_settings['MIN_SEARCH_WORD_LENGTH']

    need_scope_links = askbot_settings.ALL_SCOPE_ENABLED or \
        askbot_settings.UNANSWERED_SCOPE_ENABLED or \
        (request.user.is_authenticated and askbot_settings.FOLLOWED_SCOPE_ENABLED)

    context = {
        'base_url': site_url(''),
        'csrf_token': csrf.get_token(request),
        'empty_search_state': SearchState.get_empty(),
        'min_search_word_length': min_search_word_length,
        'current_language_code': current_language,
        'settings': my_settings,
        'moderation_items': api.get_info_on_moderation_items(request.user),
        'need_scope_links': need_scope_links,
        'noscript_url': const.DEPENDENCY_URLS['noscript'],
    }

    use_askbot_login = '******' in settings.INSTALLED_APPS
    my_settings['USE_ASKBOT_LOGIN_SYSTEM'] = use_askbot_login
    if use_askbot_login and request.user.is_anonymous:
        from askbot.deps.django_authopenid import context as login_context
        context.update(login_context.login_context(request))

    context['group_list'] = json.dumps(make_group_list())

    if askbot_settings.EDITOR_TYPE == 'tinymce':
        from tinymce.widgets import TinyMCE
        context['tinymce'] = TinyMCE()

    return context
Exemplo n.º 23
0
def application_settings(request):
    """The context processor function"""
    if not request.path.startswith("/" + settings.ASKBOT_URL):
        # todo: this is a really ugly hack, will only work
        # when askbot is installed not at the home page.
        # this will not work for the
        # heavy modders of askbot, because their custom pages
        # will not receive the askbot settings in the context
        # to solve this properly we should probably explicitly
        # add settings to the context per page
        return {}
    my_settings = askbot_settings.as_dict()
    my_settings["LANGUAGE_CODE"] = getattr(request, "LANGUAGE_CODE", settings.LANGUAGE_CODE)
    my_settings["MULTILINGUAL"] = getattr(settings, "ASKBOT_MULTILINGUAL", False)
    my_settings["LANGUAGES_DICT"] = dict(getattr(settings, "LANGUAGES", []))
    my_settings["ALLOWED_UPLOAD_FILE_TYPES"] = settings.ASKBOT_ALLOWED_UPLOAD_FILE_TYPES
    my_settings["ASKBOT_URL"] = settings.ASKBOT_URL
    my_settings["STATIC_URL"] = settings.STATIC_URL
    my_settings["IP_MODERATION_ENABLED"] = getattr(settings, "ASKBOT_IP_MODERATION_ENABLED", False)
    my_settings["ASKBOT_CSS_DEVEL"] = getattr(settings, "ASKBOT_CSS_DEVEL", False)
    my_settings["USE_LOCAL_FONTS"] = getattr(settings, "ASKBOT_USE_LOCAL_FONTS", False)
    my_settings["CSRF_COOKIE_NAME"] = settings.CSRF_COOKIE_NAME
    my_settings["DEBUG"] = settings.DEBUG
    my_settings["USING_RUNSERVER"] = "runserver" in sys.argv
    my_settings["ASKBOT_VERSION"] = askbot.get_version()
    my_settings["LOGIN_URL"] = url_utils.get_login_url()
    my_settings["LOGOUT_URL"] = url_utils.get_logout_url()

    if my_settings["EDITOR_TYPE"] == "tinymce":
        tinymce_plugins = settings.TINYMCE_DEFAULT_CONFIG.get("plugins", "").split(",")
        my_settings["TINYMCE_PLUGINS"] = map(lambda v: v.strip(), tinymce_plugins)
    else:
        my_settings["TINYMCE_PLUGINS"] = []

    my_settings["LOGOUT_REDIRECT_URL"] = url_utils.get_logout_redirect_url()
    my_settings["USE_ASKBOT_LOGIN_SYSTEM"] = "askbot.deps.django_authopenid" in settings.INSTALLED_APPS

    current_language = get_language()

    # for some languages we will start searching for shorter words
    if current_language == "ja":
        # we need to open the search box and show info message about
        # the japanese lang search
        min_search_word_length = 1
    else:
        min_search_word_length = my_settings["MIN_SEARCH_WORD_LENGTH"]

    context = {
        "base_url": site_url(""),
        "min_search_word_length": min_search_word_length,
        "current_language_code": current_language,
        "settings": my_settings,
        "skin": get_skin(),
        "moderation_items": api.get_info_on_moderation_items(request.user),
        "noscript_url": const.DEPENDENCY_URLS["noscript"],
    }

    if askbot_settings.GROUPS_ENABLED:
        # calculate context needed to list all the groups
        def _get_group_url(group):
            """calculates url to the group based on its id and name"""
            group_slug = slugify(group["name"])
            return reverse("users_by_group", kwargs={"group_id": group["id"], "group_slug": group_slug})

        # load id's and names of all groups
        global_group = models.Group.objects.get_global_group()
        groups = models.Group.objects.exclude_personal()
        groups = groups.exclude(id=global_group.id)
        groups_data = list(groups.values("id", "name"))

        # sort groups_data alphanumerically, but case-insensitive
        groups_data = sorted(groups_data, lambda x, y: cmp(x["name"].lower(), y["name"].lower()))

        # insert data for the global group at the first position
        groups_data.insert(0, {"id": global_group.id, "name": global_group.name})

        # build group_list for the context
        group_list = list()
        for group in groups_data:
            link = _get_group_url(group)
            group_list.append({"name": group["name"], "link": link})
        context["group_list"] = simplejson.dumps(group_list)

    return context
Exemplo n.º 24
0
from __future__ import print_function
import ez_setup
ez_setup.use_setuptools()
from setuptools import setup, find_packages
import sys

#NOTE: if you want to develop askbot
#you might want to install django-debug-toolbar as well

import askbot

setup(
    name = "askbot",
    version = askbot.get_version(),#remember to manually set this correctly
    description = 'Question and Answer forum, like StackOverflow, written in python and Django',
    packages = find_packages(),
    author = 'Evgeny.Fadeev',
    author_email = '*****@*****.**',
    license = 'GPLv3',
    keywords = 'forum, community, wiki, Q&A',
    entry_points = {
        'console_scripts' : [
            'askbot-setup = askbot.deployment:askbot_setup',
        ]
    },
    url = 'http://askbot.org',
    include_package_data = True,
    install_requires = askbot.REQUIREMENTS.values(),
    classifiers = [
        'Development Status :: 4 - Beta',
        'Environment :: Web Environment',
Exemplo n.º 25
0
def application_settings(request):
    """The context processor function"""
    if not request.path.startswith('/' + settings.ASKBOT_URL):
        #todo: this is a really ugly hack, will only work
        #when askbot is installed not at the home page.
        #this will not work for the
        #heavy modders of askbot, because their custom pages
        #will not receive the askbot settings in the context
        #to solve this properly we should probably explicitly
        #add settings to the context per page
        return {}
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE',
                                           settings.LANGUAGE_CODE)
    my_settings['ALLOWED_UPLOAD_FILE_TYPES'] = \
            settings.ASKBOT_ALLOWED_UPLOAD_FILE_TYPES
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['STATIC_URL'] = settings.STATIC_URL
    my_settings['ASKBOT_CSS_DEVEL'] = getattr(settings, 'ASKBOT_CSS_DEVEL',
                                              False)
    my_settings['USE_LOCAL_FONTS'] = getattr(settings,
                                             'ASKBOT_USE_LOCAL_FONTS', False)
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['USING_RUNSERVER'] = 'runserver' in sys.argv
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    my_settings['LOGIN_URL'] = url_utils.get_login_url()
    my_settings['LOGOUT_URL'] = url_utils.get_logout_url()
    my_settings['LOGOUT_REDIRECT_URL'] = url_utils.get_logout_redirect_url()
    my_settings['USE_ASKBOT_LOGIN_SYSTEM'] = 'askbot.deps.django_authopenid' \
        in settings.INSTALLED_APPS
    context = {
        'settings': my_settings,
        'skin': get_skin(request),
        'moderation_items': api.get_info_on_moderation_items(request.user),
        'noscript_url': const.DEPENDENCY_URLS['noscript'],
    }

    if askbot_settings.GROUPS_ENABLED:
        #calculate context needed to list all the groups
        def _get_group_url(group):
            """calculates url to the group based on its id and name"""
            group_slug = slugify(group['name'])
            return reverse('users_by_group',
                           kwargs={
                               'group_id': group['id'],
                               'group_slug': group_slug
                           })

        #load id's and names of all groups
        global_group = models.Group.objects.get_global_group()
        groups = models.Group.objects.exclude_personal()
        groups = groups.exclude(id=global_group.id)
        groups_data = list(groups.values('id', 'name'))

        #sort groups_data alphanumerically, but case-insensitive
        groups_data = sorted(
            groups_data,
            lambda x, y: cmp(x['name'].lower(), y['name'].lower()))

        #insert data for the global group at the first position
        groups_data.insert(0, {
            'id': global_group.id,
            'name': global_group.name
        })

        #build group_list for the context
        group_list = list()
        for group in groups_data:
            link = _get_group_url(group)
            group_list.append({'name': group['name'], 'link': link})
        context['group_list'] = simplejson.dumps(group_list)

    return context
Exemplo n.º 26
0
def application_settings(request):
    """The context processor function"""
    if not request.path.startswith('/' + settings.ASKBOT_URL):
        #todo: this is a really ugly hack, will only work
        #when askbot is installed not at the home page.
        #this will not work for the
        #heavy modders of askbot, because their custom pages
        #will not receive the askbot settings in the context
        #to solve this properly we should probably explicitly
        #add settings to the context per page
        return {}
    my_settings = askbot_settings.as_dict()
    my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
    my_settings['MULTILINGUAL'] = getattr(settings, 'ASKBOT_MULTILINGUAL', False)
    my_settings['LANGUAGES'] = getattr(settings, 'LANGUAGES', [])
    my_settings['ALLOWED_UPLOAD_FILE_TYPES'] = \
            settings.ASKBOT_ALLOWED_UPLOAD_FILE_TYPES
    my_settings['ASKBOT_URL'] = settings.ASKBOT_URL
    my_settings['STATIC_URL'] = settings.STATIC_URL
    my_settings['ASKBOT_CSS_DEVEL'] = getattr(
                                        settings,
                                        'ASKBOT_CSS_DEVEL',
                                        False
                                    )
    my_settings['USE_LOCAL_FONTS'] = getattr(
                                        settings,
                                        'ASKBOT_USE_LOCAL_FONTS',
                                        False
                                    )
    my_settings['DEBUG'] = settings.DEBUG
    my_settings['USING_RUNSERVER'] = 'runserver' in sys.argv
    my_settings['ASKBOT_VERSION'] = askbot.get_version()
    my_settings['LOGIN_URL'] = url_utils.get_login_url()
    my_settings['LOGOUT_URL'] = url_utils.get_logout_url()
    my_settings['LOGOUT_REDIRECT_URL'] = url_utils.get_logout_redirect_url()
    my_settings['USE_ASKBOT_LOGIN_SYSTEM'] = 'askbot.deps.django_authopenid' \
        in settings.INSTALLED_APPS
    context = {
        'settings': my_settings,
        'skin': get_skin(request),
        'moderation_items': api.get_info_on_moderation_items(request.user),
        'noscript_url': const.DEPENDENCY_URLS['noscript'],
    }

    if askbot_settings.GROUPS_ENABLED:
        #calculate context needed to list all the groups
        def _get_group_url(group):
            """calculates url to the group based on its id and name"""
            group_slug = slugify(group['name'])
            return reverse(
                'users_by_group',
                kwargs={'group_id': group['id'], 'group_slug': group_slug}
            )

        #load id's and names of all groups
        global_group = models.Group.objects.get_global_group()
        groups = models.Group.objects.exclude_personal()
        groups = groups.exclude(id=global_group.id)
        groups_data = list(groups.values('id', 'name'))

        #sort groups_data alphanumerically, but case-insensitive
        groups_data = sorted(
                        groups_data,
                        lambda x, y: cmp(x['name'].lower(), y['name'].lower())
                    )

        #insert data for the global group at the first position
        groups_data.insert(0, {'id': global_group.id, 'name': global_group.name})

        #build group_list for the context
        group_list = list()
        for group in groups_data:
            link = _get_group_url(group)
            group_list.append({'name': group['name'], 'link': link})
        context['group_list'] = simplejson.dumps(group_list)

    return context
Exemplo n.º 27
0
# The encoding of source files.
#source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'Askbot'
copyright = u'2011, Askbot Project'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
# The short X.Y version.
from askbot import get_version
version = get_version()
# The full version, including alpha/beta/rc tags.
release = get_version()

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.