Example #1
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.persona')

    routes = [
        ('mediagoblin.plugins.persona.login',
         '/auth/persona/login/',
         'mediagoblin.plugins.persona.views:login'),
        ('mediagoblin.plugins.persona.register',
         '/auth/persona/register/',
         'mediagoblin.plugins.persona.views:register'),
        ('mediagoblin.plugins.persona.edit',
         '/edit/persona/',
         'mediagoblin.plugins.persona.views:edit'),
        ('mediagoblin.plugins.persona.add',
         '/edit/persona/add/',
         'mediagoblin.plugins.persona.views:add')]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
    pluginapi.register_template_hooks(
        {'persona_end': 'mediagoblin/plugins/persona/persona_js_end.html',
         'persona_form': 'mediagoblin/plugins/persona/persona.html',
         'edit_link': 'mediagoblin/plugins/persona/edit_link.html',
         'login_link': 'mediagoblin/plugins/persona/login_link.html',
         'register_link': 'mediagoblin/plugins/persona/register_link.html'})
Example #2
0
def search_results_view(request, page):
    media_entries = None
    pagination = None
    form = indexedsearch.forms.SearchForm(request.form)

    config = pluginapi.get_config('indexedsearch')
    if config.get('SEARCH_LINK_STYLE') == 'form':
        form.show = False
    else:
        form.show = True

    query = None
    if request.method == 'GET' and 'q' in request.GET:
        query = request.GET['q']

    if query:
        engine = get_engine()
        result_ids = engine.search(query)

        if result_ids:
            matches = MediaEntry.query.filter(
                MediaEntry.id.in_(result_ids))
            pagination = Pagination(page, matches)
            media_entries = pagination()

    return render_to_response(
        request,
        'indexedsearch/results.html',
        {'media_entries': media_entries,
         'pagination': pagination,
         'form': form})
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.oauth')

    _log.info('Setting up OAuth...')
    _log.debug('OAuth config: {0}'.format(config))

    routes = [
        ('mediagoblin.plugins.oauth.authorize', '/oauth-2/authorize',
         'mediagoblin.plugins.oauth.views:authorize'),
        ('mediagoblin.plugins.oauth.authorize_client',
         '/oauth-2/client/authorize',
         'mediagoblin.plugins.oauth.views:authorize_client'),
        ('mediagoblin.plugins.oauth.access_token', '/oauth-2/access_token',
         'mediagoblin.plugins.oauth.views:access_token'),
        ('mediagoblin.plugins.oauth.list_connections',
         '/oauth-2/client/connections',
         'mediagoblin.plugins.oauth.views:list_connections'),
        ('mediagoblin.plugins.oauth.register_client',
         '/oauth-2/client/register',
         'mediagoblin.plugins.oauth.views:register_client'),
        ('mediagoblin.plugins.oauth.list_clients', '/oauth-2/client/list',
         'mediagoblin.plugins.oauth.views:list_clients')
    ]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
Example #4
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.basic_auth')

    routes = [('mediagoblin.plugins.basic_auth.edit.pass', '/edit/password/',
               'mediagoblin.plugins.basic_auth.views:change_pass'),
              ('mediagoblin.plugins.basic_auth.forgot_password',
               '/auth/forgot_password/',
               'mediagoblin.plugins.basic_auth.views:forgot_password'),
              ('mediagoblin.plugins.basic_auth.verify_forgot_password',
               '/auth/forgot_password/verify/',
               'mediagoblin.plugins.basic_auth.views:verify_forgot_password')]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks({
        'edit_link':
        'mediagoblin/plugins/basic_auth/edit_link.html',
        'fp_link':
        'mediagoblin/plugins/basic_auth/fp_link.html',
        'fp_head':
        'mediagoblin/plugins/basic_auth/fp_head.html',
        'create_account':
        'mediagoblin/plugins/basic_auth/create_account_link.html'
    })
Example #5
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.subtitles')

    routes = [('mediagoblin.plugins.subtitles.customize',
               '/u/<string:user>/m/<int:media_id>/customize/<int:id>',
               'mediagoblin.plugins.subtitles.views:custom_subtitles'),
              ('mediagoblin.plugins.subtitles.subtitles',
               '/u/<string:user>/m/<int:media_id>/subtitles/',
               'mediagoblin.plugins.subtitles.views:edit_subtitles'),
              ('mediagoblin.plugins.subtitles.delete_subtitles',
               '/u/<string:user>/m/<int:media_id>/delete/<int:id>',
               'mediagoblin.plugins.subtitles.views:delete_subtitles')]

    pluginapi.register_routes(routes)

    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks({
        "customize_subtitles":
        "mediagoblin/plugins/subtitles/custom_subtitles.html",
        "add_subtitles":
        "mediagoblin/plugins/subtitles/subtitles.html",
        "subtitle_sidebar":
        "mediagoblin/plugins/subtitles/subtitle_media_block.html"
    })
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.persona')

    routes = [
        ('mediagoblin.plugins.persona.login', '/auth/persona/login/',
         'mediagoblin.plugins.persona.views:login'),
        ('mediagoblin.plugins.persona.register', '/auth/persona/register/',
         'mediagoblin.plugins.persona.views:register'),
        ('mediagoblin.plugins.persona.edit', '/edit/persona/',
         'mediagoblin.plugins.persona.views:edit'),
        ('mediagoblin.plugins.persona.add', '/edit/persona/add/',
         'mediagoblin.plugins.persona.views:add')
    ]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
    pluginapi.register_template_hooks({
        'persona_end':
        'mediagoblin/plugins/persona/persona_js_end.html',
        'persona_form':
        'mediagoblin/plugins/persona/persona.html',
        'edit_link':
        'mediagoblin/plugins/persona/edit_link.html',
        'login_link':
        'mediagoblin/plugins/persona/login_link.html',
        'register_link':
        'mediagoblin/plugins/persona/register_link.html'
    })
def setup_plugin():
    _log.info('Setting up lepturecaptcha...')

    config = pluginapi.get_config('mediagoblin.plugins.lepturecaptcha')
    if config:
        if config.get('CAPTCHA_SECRET_PHRASE') == 'changeme':
            configuration_error = 'You must configure the captcha secret phrase.'
            raise ImproperlyConfigured(configuration_error)

    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {'register_captcha': 'mediagoblin/plugins/lepturecaptcha/captcha_challenge.html'})

    # Create dummy request object to find register_form.
    environ = create_environ('/foo', 'http://localhost:8080/')
    request = Request(environ)
    register_form = pluginapi.hook_handle("auth_get_registration_form", request)
    del request

    # Add plugin-specific fields to register_form class.
    register_form_class = register_form.__class__
    register_form_class.captcha_response = captcha_forms.CaptchaStringField('CAPTCHA response', id='captcha_response', name='captcha_response')
    register_form_class.captcha_hash = wtforms.HiddenField('')
    register_form_class.remote_address = wtforms.HiddenField('')

    _log.info('Done setting up lepturecaptcha!')
Example #8
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.openid')

    routes = [
        ('mediagoblin.plugins.openid.register',
         '/auth/openid/register/',
         'mediagoblin.plugins.openid.views:register'),
        ('mediagoblin.plugins.openid.login',
         '/auth/openid/login/',
         'mediagoblin.plugins.openid.views:login'),
        ('mediagoblin.plugins.openid.finish_login',
         '/auth/openid/login/finish/',
         'mediagoblin.plugins.openid.views:finish_login'),
        ('mediagoblin.plugins.openid.edit',
         '/edit/openid/',
         'mediagoblin.plugins.openid.views:start_edit'),
        ('mediagoblin.plugins.openid.finish_edit',
         '/edit/openid/finish/',
         'mediagoblin.plugins.openid.views:finish_edit'),
        ('mediagoblin.plugins.openid.delete',
         '/edit/openid/delete/',
         'mediagoblin.plugins.openid.views:delete_openid'),
        ('mediagoblin.plugins.openid.finish_delete',
         '/edit/openid/delete/finish/',
         'mediagoblin.plugins.openid.views:finish_delete')]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {'register_link': 'mediagoblin/plugins/openid/register_link.html',
         'login_link': 'mediagoblin/plugins/openid/login_link.html',
         'edit_link': 'mediagoblin/plugins/openid/edit_link.html'})
def setup_plugin():
    """Setup plugin by adding routes and templates to mediagoblin"""

    _log.info('Setting up routes and templates')
    config = pluginapi.get_config('indexedsearch')

    if config.get('USERS_ONLY'):
        view = 'user_search_results_view'
    else:
        view = 'search_results_view'

    routes = [
        ('indexedsearch',
         '/search/',
         'mediagoblin.plugins.indexedsearch.views:' + view)]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    search_link_style = config.get('SEARCH_LINK_STYLE')
    _log.debug("Search link style was specified as: %r", search_link_style)

    if search_link_style in ['button', 'link', 'none', 'form']:
        header_template = ('indexedsearch/search_link_%s.html' %
                           search_link_style)
    else:
        header_template = 'indexedsearch/search_link_form.html'

    pluginapi.register_template_hooks(
        {'header_extra': header_template})
Example #10
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.oauth')

    _log.info('Setting up OAuth...')
    _log.debug('OAuth config: {0}'.format(config))

    routes = [
       ('mediagoblin.plugins.oauth.authorize',
            '/oauth/authorize',
            'mediagoblin.plugins.oauth.views:authorize'),
        ('mediagoblin.plugins.oauth.authorize_client',
            '/oauth/client/authorize',
            'mediagoblin.plugins.oauth.views:authorize_client'),
        ('mediagoblin.plugins.oauth.access_token',
            '/oauth/access_token',
            'mediagoblin.plugins.oauth.views:access_token'),
        ('mediagoblin.plugins.oauth.list_connections',
            '/oauth/client/connections',
            'mediagoblin.plugins.oauth.views:list_connections'),
        ('mediagoblin.plugins.oauth.register_client',
            '/oauth/client/register',
            'mediagoblin.plugins.oauth.views:register_client'),
        ('mediagoblin.plugins.oauth.list_clients',
            '/oauth/client/list',
            'mediagoblin.plugins.oauth.views:list_clients')]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
Example #11
0
def setup_plugin():
    _log.info('Setting up recaptcha...')

    config = pluginapi.get_config('mediagoblin.plugins.recaptcha')
    if config:
        if config.get('RECAPTCHA_SITE_KEY') == 'domainsitekey':
            configuration_error = 'You must configure the recaptcha plugin site key.'
            raise ImproperlyConfigured(configuration_error)
        if config.get('RECAPTCHA_SECRET_KEY') == 'domainsecretkey':
            configuration_error = 'You must configure the recaptcha plugin secret key.'
            raise ImproperlyConfigured(configuration_error)

    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks({
        'register_captcha':
        'mediagoblin/plugins/recaptcha/captcha_challenge.html'
    })

    # Create dummy request object to find register_form.
    environ = create_environ('/foo', 'http://localhost:8080/')
    request = Request(environ)
    register_form = pluginapi.hook_handle("auth_get_registration_form",
                                          request)
    del request

    # Add plugin-specific fields to register_form class.
    register_form_class = register_form.__class__
    register_form_class.g_recaptcha_response = captcha_forms.RecaptchaHiddenField(
        'reCAPTCHA', id='g-recaptcha-response', name='g-recaptcha-response')
    register_form_class.remote_address = wtforms.HiddenField('')

    _log.info('Done setting up recaptcha!')
def extra_validation(register_form):
    config = pluginapi.get_config('mediagoblin.plugins.lepturecaptcha')
    captcha_secret = config.get('CAPTCHA_SECRET_PHRASE')

    if 'captcha_response' in register_form:
        captcha_response = register_form.captcha_response.data
    if 'captcha_hash' in register_form:
        captcha_hash = register_form.captcha_hash.data
        if captcha_hash == u'':
            for raw_data in register_form.captcha_hash.raw_data:
                if raw_data != u'':
                    captcha_hash = raw_data
    if 'remote_address' in register_form:
        remote_address = register_form.remote_address.data
        if remote_address == u'':
            for raw_data in register_form.remote_address.raw_data:
                if raw_data != u'':
                    remote_address = raw_data

    captcha_challenge_passes = False

    if captcha_response and captcha_hash:
        captcha_response_hash = sha1(captcha_secret + captcha_response).hexdigest()
        captcha_challenge_passes = (captcha_response_hash == captcha_hash)

    if not captcha_challenge_passes:
        register_form.captcha_response.errors.append(
            _('Sorry, CAPTCHA attempt failed.'))
        _log.info('Failed registration CAPTCHA attempt from %r.', remote_address)
        _log.debug('captcha response is: %r', captcha_response)
        _log.debug('captcha hash is: %r', captcha_hash)
        _log.debug('captcha response hash is: %r', captcha_response_hash)

    return captcha_challenge_passes
def setup_plugin():
    """Setup plugin by adding routes and templates to mediagoblin"""

    _log.info('Setting up routes and templates')
    config = pluginapi.get_config('indexedsearch')

    if config.get('USERS_ONLY'):
        view = 'user_search_results_view'
    else:
        view = 'search_results_view'

    routes = [
        ('indexedsearch',
         '/search/',
         'indexedsearch.views:' + view)]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    search_link_style = config.get('SEARCH_LINK_STYLE')
    _log.debug("Search link style was specified as: %r", search_link_style)

    if search_link_style in ['button', 'link', 'none', 'form']:
        header_template = ('indexedsearch/search_link_%s.html' %
                           search_link_style)
    else:
        header_template = 'indexedsearch/search_link_form.html'

    pluginapi.register_template_hooks(
        {'header_extra': header_template})
def get_registration_form(request):
    config = pluginapi.get_config('mediagoblin.plugins.recaptcha2')
    return recaptcha2_forms.RegistrationForm(request.form,
                                             site_key=config.get('RECAPTCHA_SITE_KEY'),
                                             secret_key=config.get('RECAPTCHA_SECRET_KEY'),
                                             captcha={
                                                'ip_address': request.remote_addr,
                                             })
Example #15
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.geolocation')

    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {"location_info": "mediagoblin/plugins/geolocation/map.html",
         "location_head": "mediagoblin/plugins/geolocation/map_js_head.html"})
Example #16
0
def setup_plugin():
	_log.info("Plugin loading")
	config = get_config('uploadurl')
	if config:
		_log.info('%r' % config)
	else:
		_log.info("no config found continuing")

	register_routes(('upload', '/upload', 'uploadurl.views:upload_handler'))
Example #17
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.geolocation')
    
    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {"image_sideinfo": "mediagoblin/plugins/geolocation/map.html",
         "image_head": "mediagoblin/plugins/geolocation/map_js_head.html"})
Example #18
0
def setup_plugin():
    _log.info("Plugin loading")
    config = get_config('uploadurl')
    if config:
        _log.info('%r' % config)
    else:
        _log.info("no config found continuing")

    register_routes(('upload', '/upload', 'uploadurl.views:upload_handler'))
Example #19
0
def setup_plugin():
    _log.info('Setting up YunoHost SSO Auth...')

    config = pluginapi.get_config('ynhauth')
    if 'admin' in config:
        global ADMIN_USERNAME
        ADMIN_USERNAME = config['admin']

    ENABLED_MEDDLEWARE.append('ynhauth.meddleware:YnhAuthMeddleware')
Example #20
0
def setup_plugin():
    global _setup_plugin_called

    _log.info('Sample plugin set up!')
    config = get_config('mediagoblin.plugins.sampleplugin')
    if config:
        _log.info('%r' % config)
    else:
        _log.info('There is no configuration set.')
    _setup_plugin_called += 1
Example #21
0
def setup_plugin():
    global _setup_plugin_called

    _log.info('Sample plugin set up!')
    config = get_config('mediagoblin.plugins.sampleplugin')
    if config:
        _log.info('%r' % config)
    else:
        _log.info('There is no configuration set.')
    _setup_plugin_called += 1
def register(request):
#    if request.method == 'GET':
#        return redirect(
#            request,
#            'mediagoblin.plugins.recaptcha.register')

    register_form = auth_forms.RegistrationForm(request.form)
    config = pluginapi.get_config('mediagoblin.plugins.recaptcha')

    recaptcha_protocol = ''
    if config['RECAPTCHA_USE_SSL']:
        recaptcha_protocol = 'https'
    else:
        recaptcha_protocol = 'http'
    _log.debug("Connecting to reCAPTCHA service via %r", recaptcha_protocol)

    if register_form.validate():
        recaptcha_challenge = request.form['recaptcha_challenge_field']
        recaptcha_response = request.form['recaptcha_response_field']
        _log.debug("response field is: %r", recaptcha_response)
        _log.debug("challenge field is: %r", recaptcha_challenge)
        response = captcha.submit(
            recaptcha_challenge,
            recaptcha_response,
            config.get('RECAPTCHA_PRIVATE_KEY'),
            request.remote_addr,
            )

        goblin = response.is_valid
        if response.error_code:
            _log.warning("reCAPTCHA error: %r", response.error_code)

        if goblin:
            user = register_user(request, register_form)

            if user:
                # redirect the user to their homepage... there will be a
                # message waiting for them to verify their email
                return redirect(
                    request, 'mediagoblin.user_pages.user_home',
                    user=user.username)

        else:
            messages.add_message(
                request,
                messages.WARNING,
                _('Sorry, captcha was incorrect. Please try again.'))

    return render_to_response(
        request,
        'mediagoblin/plugins/recaptcha/register.html',
        {'register_form': register_form,
         'post_url': request.urlgen('mediagoblin.plugins.recaptcha.register'),
         'recaptcha_public_key': config.get('RECAPTCHA_PUBLIC_KEY'),
         'recaptcha_protocol' : recaptcha_protocol})
Example #23
0
def setup_plugin():
    _log.info('Setting up embedcode plugin...')
    config = pluginapi.get_config('mediagoblin.plugins.embedcode')

    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {'media_sideinfo': 'mediagoblin/plugins/embedcode/embed_code.html'})

    _log.info('Done setting up embedcode!')
Example #24
0
def setup_plugin():
    config = pluginapi.get_config(MEDIA_TYPE)
    _log.info("setting up blog media type plugin.")

    routes = [
        #blog_create
        ('mediagoblin.media_types.blog.create', '/u/<string:user>/b/create/',
         'mediagoblin.media_types.blog.views:blog_edit'),
        #blog_edit
        ('mediagoblin.media_types.blog.edit',
         '/u/<string:user>/b/<string:blog_slug>/edit/',
         'mediagoblin.media_types.blog.views:blog_edit'),
        #blog post create
        ('mediagoblin.media_types.blog.blogpost.create',
         '/u/<string:user>/b/<string:blog_slug>/p/create/',
         'mediagoblin.media_types.blog.views:blogpost_create'),
        #blog post edit
        ('mediagoblin.media_types.blog.blogpost.edit',
         '/u/<string:user>/b/<string:blog_slug>/p/<string:blog_post_slug>/edit/',
         'mediagoblin.media_types.blog.views:blogpost_edit'),
        #blog collection dashboard in case of multiple blogs
        ('mediagoblin.media_types.blog.blog_admin_dashboard',
         '/u/<string:user>/b/dashboard/',
         'mediagoblin.media_types.blog.views:blog_dashboard'),
        #blog dashboard
        ('mediagoblin.media_types.blog.blog-dashboard',
         '/u/<string:user>/b/<string:blog_slug>/dashboard/',
         'mediagoblin.media_types.blog.views:blog_dashboard'),
        #blog post listing view
        ('mediagoblin.media_types.blog.blog_post_listing',
         '/u/<string:user>/b/<string:blog_slug>/',
         'mediagoblin.media_types.blog.views:blog_post_listing'),
        #blog post draft view
        ('mediagoblin.media_types.blog.blogpost_draft_view',
         '/u/<string:user>/b/<string:blog_slug>/p/<string:blog_post_slug>/draft/',
         'mediagoblin.media_types.blog.views:draft_view'),
        #blog delete view
        ('mediagoblin.media_types.blog.blog_delete',
         '/u/<string:user>/b/<string:blog_slug>/delete/',
         'mediagoblin.media_types.blog.views:blog_delete'),
        # blog about view
        ('mediagoblin.media_types.blog.blog_about',
         '/u/<string:user>/b/<string:blog_slug>/about/',
         'mediagoblin.media_types.blog.views:blog_about_view')
    ]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
    pluginapi.register_template_hooks({
        "user_profile":
        "mediagoblin/blog/url_to_blogs_dashboard.html",
        "blog_dashboard_home":
        "mediagoblin/blog/url_to_dashboard.html",
    })
Example #25
0
def setup_plugin():
    global config 
    config = pluginapi.get_config('advanced-sampleplugin')
    if config:
        _log.info('%r' % config)
    else:
        _log.info('There is no configuration set.')
    
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {"persona_end": "mediagoblin/advanced-sampleplugin/template.html"})
Example #26
0
def setup_plugin():
    config = pluginapi.get_config("mediagoblin.plugins.geolocation")

    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, "templates"))

    pluginapi.register_template_hooks(
        {
            "location_info": "mediagoblin/plugins/geolocation/map.html",
            "location_head": "mediagoblin/plugins/geolocation/map_js_head.html",
        }
    )
def setup_plugin():
	_log.info("Starting podcaster")
	config = get_config('podcast')
	if config:
		_log.info("CONFIG FOUND")
	else:
		_log.info("CONFIG NOT FOUND")

	register_routes([('makeapodcast','/makeapodcast.html','podcast.views:register_podcast'),
		('podcast.rssfeed', '/u/<string:user>/podcast', 'podcast.views:get_podcasts'),
		('podcast.createpodcast','/podcast/create','podcast.views:create_podcast'),
		('podcast.listpodcast', '/u/<string:user>/listpodcast', 'podcast.views:list_podcast')])
	register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
Example #28
0
def setup_plugin():
    _log.info('Setting up Search...')

    config = pluginapi.get_config(__name__)

    _log.debug('Search config: {0}'.format(config))

    routes = [
        ('mediagoblin.plugins.search.search', '/search',
         'mediagoblin.plugins.search.views:search'),
    ]

    pluginapi.register_routes(routes)
Example #29
0
def setup_plugin():
    _log.info('Setting up Search...')

    config = pluginapi.get_config(__name__)

    _log.debug('Search config: {0}'.format(config))

    routes = [
        ('mediagoblin.plugins.search.search',
            '/search',
            'mediagoblin.plugins.search.views:search'),
    ]

    pluginapi.register_routes(routes)
Example #30
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin_picscout')

    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
    pluginapi.register_template_hooks(
        {"image_sideinfo": "mediagoblin/plugins/picscout/sideinfo.html"})

    routes = [
        ('mediagoblin_picscout.api',
         '/api/picscout/picscout_lookup',
         'mediagoblin_picscout.api:picscout_lookup')
    ]

    pluginapi.register_routes(routes)
Example #31
0
def setup_plugin():
    _log.info("Setting up Blogging plugin")
    config = pluginapi.get_config('mediagoblin.plugins.blog')
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
    routes = [
        ('mediagoblin.plugins.blog.blogpost.edit',
            '/u/<string:user>/b/post/edit/',
            'mediagoblin.plugins.blog.views:edit_blog_post'),
        ('mediagoblin.plugins.blog.blog.view',
            '/u/<string:user>/b/blog-name/',
            'mediagoblin.plugins.blog.views:view_blog')
    ]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
Example #32
0
def setup_plugin():
    _log.info('Setting up API...')

    config = pluginapi.get_config(__name__)

    _log.debug('API config: {0}'.format(config))

    routes = [('mediagoblin.plugins.api.test', '/api/test',
               'mediagoblin.plugins.api.views:api_test'),
              ('mediagoblin.plugins.api.entries', '/api/entries',
               'mediagoblin.plugins.api.views:get_entries'),
              ('mediagoblin.plugins.api.post_entry', '/api/submit',
               'mediagoblin.plugins.api.views:post_entry')]

    pluginapi.register_routes(routes)
Example #33
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.ldap')

    routes = [('mediagoblin.plugins.ldap.register', '/auth/ldap/register/',
               'mediagoblin.plugins.ldap.views:register'),
              ('mediagoblin.plugins.ldap.login', '/auth/ldap/login/',
               'mediagoblin.plugins.ldap.views:login')]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks({
        'create_account':
        'mediagoblin/plugins/ldap/create_account_link.html'
    })
Example #34
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.ldap')

    routes = [
        ('mediagoblin.plugins.ldap.register',
         '/auth/ldap/register/',
         'mediagoblin.plugins.ldap.views:register'),
        ('mediagoblin.plugins.ldap.login',
         '/auth/ldap/login/',
         'mediagoblin.plugins.ldap.views:login')]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {'create_account': 'mediagoblin/plugins/ldap/create_account_link.html'})
def add_to_form_context(context):
    config = pluginapi.get_config('mediagoblin.plugins.lepturecaptcha')
    captcha_secret = config.get('CAPTCHA_SECRET_PHRASE')
    captcha_charset = config.get('CAPTCHA_CHARACTER_SET')
    captcha_length = config.get('CAPTCHA_LENGTH')

    captcha_string = u''.join([choice(captcha_charset) for n in xrange(captcha_length)])

    captcha_hash = sha1(captcha_secret + captcha_string).hexdigest()
    context['captcha_hash'] = captcha_hash

    image = ImageCaptcha()
    data = image.generate(captcha_string)
    captcha_image = base64.b64encode(data.getvalue())
    context['captcha_image'] = captcha_image

    return context
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.html5-multi-upload')

    _log.info('Setting up html5-multi-upload....')

    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pages = config.items()

    routes = [
        ('mediagoblin.plugins.html5-multi-upload.multi_submit_start',
         '/html5-multi-upload/',
         'mediagoblin.plugins.html5-multi-upload.views:multi_submit_start')
    ]

    pluginapi.register_routes(routes)
    _log.info('Done setting up html5-multi-upload!')
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.html5-multi-upload')

    _log.info('Setting up html5-multi-upload....')

    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pages = config.items()

    routes = [
         ('mediagoblin.plugins.html5-multi-upload.multi_submit_start',
          '/html5-multi-upload/', 
          'mediagoblin.plugins.html5-multi-upload.views:multi_submit_start')
      ]

    pluginapi.register_routes(routes)
    _log.info('Done setting up html5-multi-upload!')
Example #38
0
def setup_logging():
    config = pluginapi.get_config('mediagoblin.plugins.raven')

    conf_setup_logging = False
    if config.get('setup_logging'):
        conf_setup_logging = bool(int(config.get('setup_logging')))

    if not conf_setup_logging:
        return

    from raven.handlers.logging import SentryHandler
    from raven.conf import setup_logging

    client = get_client()

    _log.info('Setting up raven logging handler')

    setup_logging(SentryHandler(client))
Example #39
0
def setup_logging():
    config = pluginapi.get_config('mediagoblin.plugins.raven')

    conf_setup_logging = False
    if config.get('setup_logging'):
        conf_setup_logging = bool(int(config.get('setup_logging')))

    if not conf_setup_logging:
        return

    from raven.handlers.logging import SentryHandler
    from raven.conf import setup_logging

    client = get_client()

    _log.info('Setting up raven logging handler')

    setup_logging(SentryHandler(client))
Example #40
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.flatpagesfile')

    _log.info('Setting up flatpagesfile....')

    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pages = config.items()

    routes = []
    for name, (url, template) in pages:
        name = 'flatpagesfile.%s' % name.strip()
        controller = flatpage_handler_builder(template)
        routes.append((name, url, controller))

    pluginapi.register_routes(routes)
    _log.info('Done setting up flatpagesfile!')
Example #41
0
def setup_plugin():
    config = pluginapi.get_config(MEDIA_TYPE)
    _log.info("setting up blog media type plugin.")
    
    routes = [  
        #blog_create
        ('mediagoblin.media_types.blog.create',                         
        '/u/<string:user>/b/create/',
        'mediagoblin.media_types.blog.views:blog_edit'
        ), 
         #blog_edit        
        ('mediagoblin.media_types.blog.edit',                          
        '/u/<string:user>/b/<string:blog_slug>/edit/',          
        'mediagoblin.media_types.blog.views:blog_edit'
        ),
        #blog post create
        ('mediagoblin.media_types.blog.blogpost.create',                
        '/u/<string:user>/b/<string:blog_slug>/p/create/',
        'mediagoblin.media_types.blog.views:blogpost_create'
        ),
        #blog post edit
        ('mediagoblin.media_types.blog.blogpost.edit',                  
        '/u/<string:user>/b/<string:blog_slug>/p/<string:blog_post_slug>/edit/',
        'mediagoblin.media_types.blog.views:blogpost_edit'
        ),
        #blog admin dashboard
        ('mediagoblin.media_types.blog.blog-dashboard',
        '/u/<string:user>/b/<string:blog_slug>/blog_dashboard/',
        'mediagoblin.media_types.blog.views:blog_dashboard'
        ),
        #blog post listing view
        ('mediagoblin.media_types.blog.blog_post_listing',
        '/u/<string:user>/b/<string:blog_slug>/',
        'mediagoblin.media_types.blog.views:blog_post_listing'
        ),
        #blog post draft view
        ('mediagoblin.media_types.blog.blogpost_draft_view', 
        '/u/<string:user>/b/<string:blog_slug>/p/<string:blog_post_slug>/draft/',
        'mediagoblin.media_types.blog.views:draft_view')
        ]
            
            
    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
Example #42
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin.plugins.flatpagesfile')

    _log.info('Setting up flatpagesfile....')

    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pages = config.items()

    routes = []
    for name, (url, template) in pages:
        name = 'flatpagesfile.%s' % name.strip()
        controller = flatpage_handler_builder(template)
        routes.append(
            (name, url, controller))

    pluginapi.register_routes(routes)
    _log.info('Done setting up flatpagesfile!')
Example #43
0
def setup_plugin():
    _log.info('Setting up API...')

    config = pluginapi.get_config(__name__)

    _log.debug('API config: {0}'.format(config))

    routes = [
        ('mediagoblin.plugins.api.test',
            '/api/test',
            'mediagoblin.plugins.api.views:api_test'),
        ('mediagoblin.plugins.api.entries',
            '/api/entries',
            'mediagoblin.plugins.api.views:get_entries'),
        ('mediagoblin.plugins.api.post_entry',
            '/api/submit',
            'mediagoblin.plugins.api.views:post_entry')]

    pluginapi.register_routes(routes)
def setup_plugin():
    _log.info('Setting up recaptcha...')
    config = pluginapi.get_config('mediagoblin.plugins.recaptcha')
    if config:
        if config.get('RECAPTCHA_USE_SSL') == True:
            _log.info('reCAPTCHA is configured to use SSL.')
        else:
            _log.info('reCAPTCHA is NOT configured to use SSL.')

        if config.get('RECAPTCHA_PUBLIC_KEY') == 'domainpublickey':
            _log.warn('reCAPTCHA public key was not specified.')
        if config.get('RECAPTCHA_PRIVATE_KEY') == 'domainprivatekey':
            _log.warn('reCAPTCHA private key was not specified.')

    routes = [
        ('mediagoblin.plugins.recaptcha.register',
         '/auth/recaptcha/register/',
         'mediagoblin.plugins.recaptcha.views:register'),
        ('mediagoblin.plugins.recaptcha.login',
         '/auth/recaptcha/login/',
         'mediagoblin.plugins.recaptcha.views:login'),
        ('mediagoblin.plugins.recaptcha.edit.pass',
         '/edit/password/',
         'mediagoblin.plugins.recaptcha.views:change_pass'),
        ('mediagoblin.plugins.recaptcha.forgot_password',
         '/auth/forgot_password/',
         'mediagoblin.plugins.recaptcha.views:forgot_password'),
        ('mediagoblin.plugins.recaptcha.verify_forgot_password',
         '/auth/forgot_password/verify/',
         'mediagoblin.plugins.recaptcha.views:verify_forgot_password')]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    pluginapi.register_template_hooks(
        {'edit_link': 'mediagoblin/plugins/recaptcha/edit_link.html',
         'fp_link': 'mediagoblin/plugins/recaptcha/fp_link.html',
         'fp_head': 'mediagoblin/plugins/recaptcha/fp_head.html',
         'create_account':
            'mediagoblin/plugins/recaptcha/create_account_link.html'})

    _log.info('Done setting up recaptcha!')
Example #45
0
def setup_plugin():
    global _setup_plugin_called

    _log.info('Setting up Piwik...')
    config = pluginapi.get_config('mediagoblin.plugins.piwik')
    if config:
        if config.get('PIWIK_DOMAIN') == 'mediagoblin.example.com':
            _log.warn('Piwik domain was not specified.')
        if config.get('PIWIK_LOCATION') == 'example.com/piwik':
            _log.warn('Piwik location was not specified.')

    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    from mediagoblin import mg_globals
    plugin_section = mg_globals.global_config.get("plugins", {})
    pluginapi.register_template_hooks(
         {"head": "mediagoblin/plugins/piwik/bits/piwik_extra_head.html"})

    _log.info('Done setting up Piwik!')
Example #46
0
def setup_plugin():
    global _setup_plugin_called

    _log.info('Setting up Piwik...')
    config = pluginapi.get_config('mediagoblin.plugins.piwik')
    if config:
        if config.get('PIWIK_DOMAIN') == 'mediagoblin.example.com':
            _log.warn('Piwik domain was not specified.')
        if config.get('PIWIK_LOCATION') == 'example.com/piwik':
            _log.warn('Piwik location was not specified.')

    # Register the template path.
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    from mediagoblin import mg_globals
    plugin_section = mg_globals.global_config.get("plugins", {})
    pluginapi.register_template_hooks(
        {"head": "mediagoblin/plugins/piwik/bits/piwik_extra_head.html"})

    _log.info('Done setting up Piwik!')
Example #47
0
def setup_plugin():
    _log.info('Setting up basic search...')
    config = pluginapi.get_config('mediagoblin.plugins.basicsearch')

    routes = [('mediagoblin.plugins.basicsearch', '/search/',
               'mediagoblin.plugins.basicsearch.views:search_results_view')]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))

    search_link_style = config.get('SEARCH_LINK_STYLE')
    _log.debug("Search link style was specified as: %r", search_link_style)
    if search_link_style == 'button':
        header_template = '/mediagoblin/plugins/basicsearch/search_link_button.html'
    elif search_link_style == 'none':
        header_template = '/mediagoblin/plugins/basicsearch/search_link_none.html'
    else:
        header_template = '/mediagoblin/plugins/basicsearch/search_link_default.html'

    pluginapi.register_template_hooks({'header_extra': header_template})
Example #48
0
def test_unprocess_media_entry(test_app):
    """
    Test that media entries that aren't marked as processed are not added to
    the index.

    """
    dirname = pluginapi.get_config('indexedsearch').get('INDEX_DIR')

    media_a = fixture_media_entry(title='mediaA', save=False,
                                  expunge=False, fake_upload=False,
                                  state='unprocessed')
    media_a.description = 'DescriptionA'
    Session.add(media_a)
    Session.commit()

    # Check that the media entry is not in the index
    ix = whoosh.index.open_dir(dirname, indexname=INDEX_NAME)
    with ix.searcher() as searcher:
        qp = whoosh.qparser.QueryParser('title', schema=ix.schema)
        query = qp.parse('mediaA')
        assert len(searcher.search(query)) == 0
Example #49
0
def get_client():
    from raven import Client
    config = pluginapi.get_config('mediagoblin.plugins.raven')

    sentry_dsn = config.get('sentry_dsn')

    client = None

    if sentry_dsn:
        _log.info('Setting up raven from plugin config: {0}'.format(
            sentry_dsn))
        client = Client(sentry_dsn)
    elif os.environ.get('SENTRY_DSN'):
        _log.info('Setting up raven from SENTRY_DSN environment variable: {0}'\
                  .format(os.environ.get('SENTRY_DSN')))
        client = Client()  # Implicitly looks for SENTRY_DSN

    if not client:
        _log.error('Could not set up client, missing sentry DSN')
        return None

    return client
Example #50
0
def get_client():
    from raven import Client
    config = pluginapi.get_config('mediagoblin.plugins.raven')

    sentry_dsn = config.get('sentry_dsn')

    client = None

    if sentry_dsn:
        _log.info(
            'Setting up raven from plugin config: {0}'.format(sentry_dsn))
        client = Client(sentry_dsn)
    elif os.environ.get('SENTRY_DSN'):
        _log.info('Setting up raven from SENTRY_DSN environment variable: {0}'\
                  .format(os.environ.get('SENTRY_DSN')))
        client = Client()  # Implicitly looks for SENTRY_DSN

    if not client:
        _log.error('Could not set up client, missing sentry DSN')
        return None

    return client
Example #51
0
def blog_dashboard(request, page, url_user=None):
    """
    Dashboard for a blog, only accessible to
    the owner of the blog.
    """
    blog_slug = request.matchdict.get('blog_slug', None)
    blogs = request.db.Blog.query.filter_by(author=url_user.id)
    config = pluginapi.get_config('mediagoblin.media_types.blog')
    max_blog_count = config['max_blog_count']
    if request.user and (request.user.id == url_user.id
                         or request.user.has_privilege(u'admin')):
        if blog_slug:
            blog = get_blog_by_slug(request, blog_slug)
            if not blog:
                return render_404(request)
            else:
                blog_posts_list = blog.get_all_blog_posts().order_by(
                    MediaEntry.created.desc())
                pagination = Pagination(page, blog_posts_list)
                pagination.per_page = 15
                blog_posts_on_a_page = pagination()
                if may_edit_blogpost(request, blog):
                    return render_to_response(
                        request, 'mediagoblin/blog/blog_admin_dashboard.html',
                        {
                            'blog_posts_list': blog_posts_on_a_page,
                            'blog_slug': blog_slug,
                            'blog': blog,
                            'user': url_user,
                            'pagination': pagination
                        })
    if not request.user or request.user.id != url_user.id or not blog_slug:
        blogs = blogs.all()
        return render_to_response(request,
                                  'mediagoblin/blog/list_of_blogs.html', {
                                      'blogs': blogs,
                                      'user': url_user,
                                      'max_blog_count': max_blog_count
                                  })
Example #52
0
def blog_dashboard(request, page, url_user=None):
    """
    Dashboard for a blog, only accessible to
    the owner of the blog.
    """
    blog_slug = request.matchdict.get('blog_slug', None)
    blogs = request.db.Blog.query.filter_by(author=url_user.id)
    config = pluginapi.get_config('mediagoblin.media_types.blog')
    max_blog_count = config['max_blog_count']
    if request.user and (request.user.id == url_user.id or request.user.has_privilege(u'admin')):
        if blog_slug:
            blog = get_blog_by_slug(request, blog_slug)
            if not blog:
                return render_404(request)
            else:
                blog_posts_list = blog.get_all_blog_posts().order_by(MediaEntry.created.desc())
                pagination = Pagination(page, blog_posts_list)
                pagination.per_page = 15
                blog_posts_on_a_page = pagination()
                if may_edit_blogpost(request, blog):
                    return render_to_response(
                        request,
                        'mediagoblin/blog/blog_admin_dashboard.html',
                        {'blog_posts_list': blog_posts_on_a_page,
                        'blog_slug':blog_slug,
                        'blog':blog,
                        'user':url_user,
                        'pagination':pagination
                        })
    if not request.user or request.user.id != url_user.id or not blog_slug:
        blogs = blogs.all()
        return render_to_response(
        request,
        'mediagoblin/blog/list_of_blogs.html',
        {
        'blogs':blogs,
        'user':url_user,
        'max_blog_count':max_blog_count
        })
Example #53
0
def setup_plugin():
    config = pluginapi.get_config(MEDIA_TYPE)
    _log.info("setting up blog media type plugin.")

    routes = [
        #blog_create
        ('mediagoblin.media_types.blog.create', '/u/<string:user>/b/create/',
         'mediagoblin.media_types.blog.views:blog_edit'),
        #blog_edit
        ('mediagoblin.media_types.blog.edit',
         '/u/<string:user>/b/<string:blog_slug>/edit/',
         'mediagoblin.media_types.blog.views:blog_edit'),
        #blog post create
        ('mediagoblin.media_types.blog.blogpost.create',
         '/u/<string:user>/b/<string:blog_slug>/p/create/',
         'mediagoblin.media_types.blog.views:blogpost_create'),
        #blog post edit
        ('mediagoblin.media_types.blog.blogpost.edit',
         '/u/<string:user>/b/<string:blog_slug>/p/<string:blog_post_slug>/edit/',
         'mediagoblin.media_types.blog.views:blogpost_edit'),
        #blog admin dashboard
        ('mediagoblin.media_types.blog.blog-dashboard',
         '/u/<string:user>/b/<string:blog_slug>/blog_dashboard/',
         'mediagoblin.media_types.blog.views:blog_dashboard'),
        #blog post listing view
        ('mediagoblin.media_types.blog.blog_post_listing',
         '/u/<string:user>/b/<string:blog_slug>/',
         'mediagoblin.media_types.blog.views:blog_post_listing'),
        #blog post draft view
        ('mediagoblin.media_types.blog.blogpost_draft_view',
         '/u/<string:user>/b/<string:blog_slug>/p/<string:blog_post_slug>/draft/',
         'mediagoblin.media_types.blog.views:draft_view')
    ]

    pluginapi.register_routes(routes)
    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
Example #54
0
def setup_plugin():
    config = pluginapi.get_config('mediagoblin_rdfa')

    pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates'))
    pluginapi.register_template_hooks(
        {"image_sideinfo": "mediagoblin/plugins/rdfa/metadata.html"})
Example #55
0
def add_to_form_context(context):
    config = pluginapi.get_config('mediagoblin.plugins.recaptcha')
    context['recaptcha_site_key'] = config.get('RECAPTCHA_SITE_KEY')
    return context