diff --git a/app.py b/app.py index c59c6bef..4e16fd92 100644 --- a/app.py +++ b/app.py @@ -29,6 +29,8 @@ def find_key(token): "*.cloudflare.com", "*.googletagmanager.com", "*.google-analytics.com", + "*.carbonads.com", + "*.carbonads.net", "'unsafe-inline'", "'unsafe-eval'", ], diff --git a/docs/_static/.gitignore b/docs/_static/.gitignore index 3e807c5f..7f2040ec 100644 --- a/docs/_static/.gitignore +++ b/docs/_static/.gitignore @@ -4,3 +4,4 @@ !.gitignore !guido.png !style.css +!carbonad.css diff --git a/docs/_static/carbonad.css b/docs/_static/carbonad.css new file mode 100644 index 00000000..38e5401e --- /dev/null +++ b/docs/_static/carbonad.css @@ -0,0 +1,90 @@ +#carbonads { + display: block; + overflow: hidden; + padding: 1em; + padding-bottom: 0.3em; + line-height: 1.5; + border: 4px solid #f5f5f5; + margin-top: 10px; + margin-bottom: 10px; +} + +#carbonads a { + text-decoration: none !important; + border-bottom: none; +} + +#carbonads a:hover { + text-decoration: none !important; +} + +#carbonads span { + display: block; + overflow: hidden; +} + +.carbon-img { + display: block; + margin: 0 auto 8px; +} + +.carbon-text { + display: block; + text-align: left; + margin-bottom: .5em; + color: #666; +} + +.carbon-poweredby { + display: block; + text-align: right; + font-size: .9em; + color: #ccc; +} + +@media only screen and (min-width: 320px) and (max-width: 875px) { + #carbonads { + float: none; + max-width: 330px; + border: 0; + display: block; + overflow: hidden; + margin-top: 20px; + margin-bottom: 20px; + border-radius: 4px; + text-align: center; + box-shadow: 0 0 0 1px hsla(0, 0%, 0%, .1); + font-size: var(--font-size); + background-color: #eee; + line-height: 1.5; + } + #carbonads span { + position: relative; + } + #carbonads > span { + max-width: none; + } + .carbon-img { + float: left; + margin: 0; + } + + .carbon-img img { + max-width: 130px !important; + } + .carbon-text { + float: left; + margin-bottom: 0; + padding: 8px 20px; + text-align: left; + color: #333 !important; + max-width: calc(100% - 130px - 3em); + } + .carbon-poweredby { + left: 130px; + bottom: 0; + display: block; + color: #555 !important; + width: 100%; + } +} diff --git a/docs/_templates/carbonad.html b/docs/_templates/carbonad.html new file mode 100644 index 00000000..f8f215f1 --- /dev/null +++ b/docs/_templates/carbonad.html @@ -0,0 +1 @@ + diff --git a/docs/conf.py b/docs/conf.py index c2d51f54..cb274865 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -134,7 +134,13 @@ # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". html_title = "pysheeet" -html_context = {"tracking_id": os.environ.get("TRACKING_ID")} +html_context = { + "tracking_id": os.environ.get("TRACKING_ID"), + "carbonad_serve": os.environ.get("CARBONAD_SERVE"), + "carbonad_placement": os.environ.get("CARBONAD_PLACEMENT") +} + +has_carbonad = os.environ.get("CARBONAD_SERVE") and os.environ.get("CARBONAD_PLACEMENT") # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None @@ -154,6 +160,8 @@ html_static_path = ['_static'] html_css_files = ['style.css'] +if has_carbonad: + html_css_files.append('carbonad.css') # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied @@ -169,23 +177,26 @@ #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -html_sidebars = { - 'index': [ - 'sidebarintro.html', - 'link.html', - 'relations.html', - 'github.html', - 'searchbox.html' - ], - '**': [ - 'sidebarintro.html', - 'link.html', - 'github.html', - 'localtoc.html', - 'relations.html', - 'searchbox.html' - ] -} +sidebar_index = [ + 'sidebarintro.html', + 'link.html', + 'github.html', +] +sidebar_notes = [ + 'sidebarintro.html', + 'link.html', + 'github.html', +] + +if has_carbonad: + sidebar_index.append('carbonad.html') + sidebar_notes.append('carbonad.html') + +sidebar_index.append('searchbox.html') +sidebar_notes.append('localtoc.html') +sidebar_notes.append('searchbox.html') +html_sidebars = {'index': sidebar_index, '**': sidebar_notes} + # Additional templates that should be rendered to pages, maps page names to # template names.