django-opengraph-meta (0.1.0b0)

Published 2024-01-31 18:49:52 +03:00 by pypi

Installation

pip install --index-url  django-opengraph-meta

About this package

Django models for OpenGraph based metadata; Server-side metadata generation

django-opengraph-meta

This package contains models, which implements containing and generating extra part of the page's meta information. It is introduced by the OpenGraph and TwitterCard entities


Package includes

Basic models:

Extra models:

TwitterCard models:


Package struct


Concepts

Database app_label

If OPENGRAPH_META_APP_LABEL would be found in django.conf.settings it will be used as prefix each db model name, exclude TwitterCards models, which use TWITTER_CARD_META_APP_LABEL

Universal page attributes:

Class methods:
  • og_name(cls)
    • Returns the OpenGraph scope name, which was set at the class initialization
  • og_properties(cls)
    • Returns the OpenGraph scope properties, which was set at the class initialization
Methods:
  • og_metadata(self)
    • Returns the Generator[Tuple[str, str]] with collected meta information. Empty fields will not be included to that selection.
  • og_name(self)
    • Return Generator[str] (wrapped metadata), which present as Iterable HTML DOM based meta tags

Universal subpage attributes

Class OGSubpage (source) is a parent of each page class, excluding the OGWebPage. It determines ForeignKey field page, which links to OGWebPage object associated for present data. It proxied two properties of the page

  • url
  • title

, to the main OGSubpage scope

Universal music attributes

Arguments *args and **kwargs will be transfer to selected object instance constructor without any modification.

Class methods:
Database fields:
  • ForeignKey audio: The audio file (source) associated with the page
    • URLField url: Contains video's url. (og:audio)
    • CharField type: Contains MIME type of the video. (og:audio:type)
    • URLField secure_url: Contains video's alternate url to use if the webpage requires HTTPS. (og:audio:secure_url)

Universal video attributes

Arguments *args and **kwargs will be transfer to selected object instance constructor without any modification.

Class methods:
Database fields:

Universal TwitterCard attributes

Class methods:
Database fields:

See also:


Basic models

OGWebPage

Database fields:
  • URLField url: Contains page's url. (og:url)
  • CharField type: Contains page's opengraph type (og:type)
  • CharField title: Contains page's title (og:type)
  • CharField description: Contains page's description (og:description)
  • ManyToManyField images: Array of the images (source) associated with the page (og:image)
    • URLField url: Contains image's url. (og:image)
    • CharField type: Contains MIME type of the image. (og:image:type)
    • URLField secure_url: Contains image's alternate url to use if the webpage requires HTTPS. (og:image:secure_url)
    • PositiveSmallIntegerField width: Contains width of the image. (og:image:width)
    • PositiveSmallIntegerField height: Contains height of the image. (og:image:height)
    • CharField alt: Contains description of what is in the image. (og:image:alt)
Properties
  • locale: Returns result of to_locale(get_language()) (og:locale)
  • locales_alt: Returns nothing, but set the interface to returning Iterable object. User may redefine this property on inheritance (og:locale:alternate)
  • determiner: Returns nothing, but set the interface to returning str. (og:determiner)
  • site_name: Returns value of OPENGRAPH_SITE_NAME (None if not present) which can be set in main project settings file

OGArticlePage

Database fields:
  • CharField section: Contains the global category value of the article (article:section)
  • DateTimeField published_time: Contains date and time of article's publication. Metadata represented as YYYY-MM-DDThh:mm (ISO 8601) string (article:published_time)
  • DateTimeField modified_time: Contains date and time of last article's modification. Metadata represented as YYYY-MM-DDThh:mm (ISO 8601) string (article:modified_time)
  • DateTimeField expiration_time: Contains date and time of article's expiration. Metadata represented as YYYY-MM-DDThh:mm (ISO 8601) string (article:expiration_time)
  • ManyToManyField authors: Contains an array of the author's profiles
    • URLField url: Contains author's page url. (article:author)
  • ManyToManyField tags: Contains an array of the tags associated with this object (article:tag)

OGBookPage

Database fields:

OGProfilePage

Database fields:
  • BooleanField is_male: Is used for handling by gender property
  • CharField first_name: First name of described person (profile:first_name)
  • CharField last_name: Last name of described person (profile:last_name)
  • CharField username: Username of described person (profile:username)
Properties
  • gender: Returns None if field is_male is null. Returns 'male' if is_male is true, 'female' in else (profile:gender)

OGMusicSongPage

Database fields:

OGMusicAlbumPage

Database fields:

OGMusicPlaylistPage

Database fields:

OGMusicRadioStationPage

Database fields:

OGVideoMoviePage


OGVideoEpisodePage


OGVideoTVShowPage


OGVideoOtherPage


Extra models

OGBusinessPage

Database fields:
  • ForeignKey contact_data: Contains link to the OGContactData property (source), which can contain:
    • CharField street_addres: Contains physical address of the object (business:contact_data:stree_addres)
    • CharField locality: Contains locality of the object (business:contact_data:locality)
    • CharField region: Contains region of the object (business:contact_data:region)
    • CharField postal_code: Contains postal_code of the object (business:contact_data:postal_code)
    • CharField country_name: Contains county name of the object (business:contact_data:country_name)
    • EmailField email: Contains email of the object (business:contact_data:email)
    • CharField phone_number: Contains phone number of the object (business:contact_data:phone_number)
    • CharField fax_number: Contains fax number of the object (business:contact_data:fax_number)
    • URLField website: Contains url to website of the object (business:contact_data:website)
  • ForeignKey place: Contains link to the OGContactData property (source), which can contain:

OGProductPage

Database fields:
Properties
  • gender: Returns unisex if field is_male is null. Returns 'male' if is_male is true, 'female' in else (product:gender)

TwitterCard models

TwitterCardApp

Database fields:

TwitterCardSummary

Database fields:
  • ForeignKey image: TwitterCardImage (source) image associated with the page
    • URLField url: Contains image's url. (twitter:image)
    • CharField alt: Contains description of what is in the image. (twitter:image:alt)
  • ForeignKey creator: TwitterCardCreator (source) profile info associated with the page
    • CharField username: @username of the creator (twitter:site)
    • CharField id: creator's Twitter ID (twitter:site:id)

TwitterCardSummaryLargeImage

Database fields:
  • ForeignKey image: TwitterCardImage (source) image associated with the page
    • URLField url: Contains image's url. (twitter:image)
    • CharField alt: Contains description of what is in the image. (twitter:image:alt)
  • ForeignKey creator: TwitterCardCreator (source) profile info associated with the page
    • CharField username: @username of the creator (twitter:site)
    • CharField id: creator's Twitter ID (twitter:site:id)

TwitterCardPlayer

Database fields:

Requirements

Requires Python: >=3.11
Details
PyPI
2024-01-31 18:49:52 +03:00
4
Gregory Lirent
56 KiB
Assets (2)
Versions (4) View all
0.1.2b1 2024-02-04
0.1.2b0 2024-02-04
0.1.1b0 2024-02-04
0.1.0b0 2024-01-31