Giter Club home page Giter Club logo

flask-sitemap's Introduction

Flask-Sitemap

image

image

image

image

image

About

Flask-Sitemap is a Flask extension helping with sitemap generation.

Installation

Flask-Sitemap is on PyPI so all you need is: :

pip install Flask-Sitemap

Documentation

Documentation is readable at http://flask-sitemap.readthedocs.io or can be built using Sphinx: :

git submodule init
git submodule update
pip install Sphinx
python setup.py build_sphinx

Testing

Running the test suite is as simple as: :

python setup.py test

or, to also show code coverage: :

./run-tests.sh

flask-sitemap's People

Contributors

albertyw avatar chawk avatar jirikuncar avatar lnielsen avatar nateeag avatar tiborsimko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flask-sitemap's Issues

Problem when using non-default block_start_string, et. al. settings on Jinja

I have a Flask stack that I reuse with a Vue frontend. Since most of my HTML templates don't use Jinja syntax much but have a lot of Vue syntax, I've changed the default delimiter options (http://svn.python.org/projects/external/Jinja-1.2/docs/html/altsyntax.html) to be based on [ instead.

However, this is a problem because this extension has embedded Jinja-based XML templates that use the default delimiters based on {. As a result, no actual Jinja rendering of the XML template occurs.

I don't think this is really a bug in flask-sitemap, but do you have any suggestions on how to deal with this? I've been source code diving on Flask and Jinja and Flask seems to only support one Jinja environment for the entire app. Jinja's Environment has a nice .overlay() method that I think would be useful in this case, but I can't find any way of using this without monkey-patching Flask which I would like to avoid.

Am I missing some more obvious way of dealing with this situation? Any other suggestions of where to look or what to try?

AssertionError: Popped wrong request context on requesting sitemap from sitemapindex

Using the following sitemap generator:

from flask import Flask
from flask_sitemap import Sitemap

app = Flask(__name__)
sitemap = Sitemap(app=app)


@app.route('/<int:some_number>')
def show_number(some_number):
    # Do stuff

@sitemap.register_generator
def sitemap():
    max_number = 100000
    for some_number in range(max_number * -1, max_number * 2):
        yield ('show_number', {'some_number': some_number})

/sitemap.xml works just fine:

$ curl http://localhost:5000/sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>http://localhost/sitemap1.xml</loc>
  </sitemap>
  <sitemap>
    <loc>http://localhost/sitemap2.xml</loc>
  </sitemap>
  …
  <sitemap>
    <loc>http://localhost/sitemap30.xml</loc>
  </sitemap>
</sitemapindex>

/sitemap1.xml, on the other hand, raises AssertionError: Popped wrong request context.

Debugging middleware caught exception in streamed response at a point where response headers were already sent.
Traceback (most recent call last):
  File "/path/to/venv/lib/python3.5/site-packages/flask/app.py", line 1994, in __call__
    return self.wsgi_app(environ, start_response)
  File "/path/to/venv/lib/python3.5/site-packages/flask/app.py", line 1990, in wsgi_app
    ctx.auto_pop(error)
  File "/path/to/venv/lib/python3.5/site-packages/flask/ctx.py", line 387, in auto_pop
    self.pop(exc)
  File "/path/to/venv/lib/python3.5/site-packages/flask/ctx.py", line 379, in pop
    '(%r instead of %r)' % (rv, self)
AssertionError: Popped wrong request context.  (<RequestContext 'http://localhost/' [GET] of number_shower> instead of <RequestContext 'http://localhost:5000/sitemap1.xml' [HEAD] of number_shower>)
127.0.0.1 - - [30/Dec/2016 10:50:34] "HEAD /sitemap1.xml HTTP/1.1" 200 -

Is there a way to exclude a url?

I have found the option "app.config['SITEMAP_INCLUDE_RULES_WITHOUT_PARAMS'] = True" which will cause all urls to be added to the sitemap, but is there an option to set this to True then just label a few that should be excluded?

Not working on python 3.10

Hi,
After installing python 3.10 following error occurred:
ImportError: cannot import name 'Mapping' from 'collections' (/usr/local/lib/python3.10/collections/init.py)

tests: python setup.py test not working

I am having some issues running the tests... I cant install the right packages.. Can you please consider adding requirements.txt. I am not familiar with setup.py, so not sure whether you need it.

I am also getting a error as Theme Error. So getting a versionconflict for coverage

Change base url

First off, thank you very much for this package. You have done something truly wonderful here.

I'm always frustrated when I can't change the base URL to what I want. For example, all the location URLs are created on localhost:5000 when the flask app runs on port 5000 on my localhost. I would like to be able to change that URL to what I want it to be.

UnicodeDecodeError getting gziped sitemap

Hi,
with flask 0.10.1 an UnicodeDecodeError happens if you try to get a gezipped sitemap.
gzip_response() function does not set the application/octet-stream content type

Probably, the problem can be fixed by adding
response.headers["Content-Type"] = "application/octet-stream"

Regards,
Chris

StopIteration exception

Hi. Can't beat this exception. Can you please help?

This is the simple code:

from flask import Flask, render_template
from flask_sitemap import Sitemap

app = Flask(__name__)
ext = Sitemap(app=app)

@app.route('/')
def home():
    return render_template('home.html')

This is the traceback:

  File "venv\lib\site-packages\flask_sitemap\__init__.py", line 130, in wrapper
    return response(new_view(*args, **kwargs))
  File "venv\lib\site-packages\flask_sitemap\__init__.py", line 138, in sitemap
    urlset = next(run)
StopIteration

Not an Issue help needed

I want to use SITEMAP_IGNORE_ENDPOINTS with multiple endpoints how do i implement this whil having SITEMAP_INCLUDE_RULES_WITHOUT_PARAMS set to true please assist

'datetime.date' object has no attribute 'update'

Package version (if known):

Describe the bug

'datetime.date' object has no attribute 'update'

Steps to Reproduce

use python 3.10
genrate the function
an try /sitemap

Expected behavior

Screenshots (if applicable)

Additional context

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.