Socialify

Folder ..

Viewing globalmetamiddleware.py
20 lines (15 loc) • 740.0 B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Middleware to add global meta tags to the HTML head


class GlobalMetaMiddleware:
    def __init__(self, get_response):
        self.get_response = get_response

    def __call__(self, request):
        request.meta = {
            # Default General Meta Tags
            "description": "Welcome to the home of Shifoo. This is my personal website where I share all of my thoughts, ideas, and experiences.",
            "image": "https://shi.foo/static/images/favicons/android-chrome-512x512.png",
            "url": "{}://{}{}".format(request.scheme, request.get_host(), request.path),
            # Robots Meta Tags
            "robots": "index, follow",
        }

        response = self.get_response(request)

        return response