enable disable ads and display ads

This commit is contained in:
Tiago Vasconcelos 2022-12-02 14:36:09 +00:00
parent f7dd533daa
commit 4410968bf5
6 changed files with 26 additions and 10 deletions

View File

@ -386,15 +386,23 @@
</q-card-section>
</q-card>
{% endif %} {% if AD_SPACE %} {% for ADS in AD_SPACE %} {% set AD =
ADS.split(';') %}
ADS.split(";") %}
<q-card>
<q-card-section>
<h6 class="text-subtitle1 q-mt-none q-mb-sm">{{ AD_TITLE }}</h6>
<h6 class="text-subtitle1 q-mt-none q-mb-sm">{{ AD_SPACE_TITLE }}</h6>
</q-card-section>
<q-card-section class="q-pa-none">
<a href="{{ AD[0] }}" class="q-ma-md">
<img v-if="($q.dark.isActive)" src="{{ AD[1] }}" />
<img v-else src="{{ AD[2] }}" />
<a style="display: inline-block" href="{{ AD[0] }}" class="q-ma-md">
<img
style="max-width: 100%; height: auto"
v-if="($q.dark.isActive)"
src="{{ AD[1] }}"
/>
<img
style="max-width: 100%; height: auto"
v-else
src="{{ AD[2] }}"
/>
</a> </q-card-section></q-card
>{% endfor %} {% endif %}
</div>

View File

@ -25,6 +25,7 @@ async def m001_create_admin_settings_table(db):
lnbits_custom_logo TEXT,
lnbits_ad_space TEXT,
lnbits_ad_space_title TEXT,
lnbits_ad_space_enabled BOOLEAN,
lnbits_data_folder TEXT,
lnbits_database_url TEXT,
lnbits_force_https TEXT,

View File

@ -25,6 +25,7 @@ class UpdateSettings(BaseModel):
lnbits_custom_logo: str = Query(None)
lnbits_ad_space: str = Query(None)
lnbits_ad_space_title: str = Query(None)
lnbits_ad_space_enabled: bool = Query(None)
# funding sources
fake_wallet_secret: str = Query(None)

View File

@ -97,6 +97,7 @@
<div class="col-12 col-md-6">
<p>Advertisement Slots</p>
<q-input
class="q-mb-md"
filled
v-model="formData.lnbits_ad_space"
type="text"
@ -104,6 +105,10 @@
hint="Ad url and image filepaths in CSV format, extensions can choose to honor"
>
</q-input>
<q-toggle
v-model="formData.lnbits_ad_space_enabled"
:label="formData.lnbits_ad_space_enabled ? 'Ads enabled' : 'Ads disabled'"
/>
<br />
</div>
</div>

View File

@ -165,8 +165,9 @@ def template_renderer(additional_folders: List = []) -> Jinja2Templates:
)
)
if settings.lnbits_ad_space:
t.env.globals["AD_SPACE"] = settings.lnbits_ad_space
if settings.lnbits_ad_space_enabled:
t.env.globals["AD_SPACE"] = settings.lnbits_ad_space.split(",")
t.env.globals["AD_SPACE_TITLE"] = settings.lnbits_ad_space_title
t.env.globals["HIDE_API"] = settings.lnbits_hide_api
t.env.globals["SITE_TITLE"] = settings.lnbits_site_title

View File

@ -62,8 +62,9 @@ class Settings(BaseSettings):
default=["classic", "flamingo", "mint", "salvador", "monochrome", "autumn"]
)
lnbits_custom_logo: str = Field(default=None)
lnbits_ad_space: str = Field(default="")
lnbits_ad_space_title: str = Field(default="")
lnbits_ad_space_title: str = Field(default="Suported by")
lnbits_ad_space: str = Field(default="https://shop.lnbits.com/;https://raw.githubusercontent.com/lnbits/lnbits/main/lnbits/static/images/lnbits-shop-light.png;https://raw.githubusercontent.com/lnbits/lnbits/main/lnbits/static/images/lnbits-shop-dark.png") # sneaky sneaky
lnbits_ad_space_enabled: bool = Field(default=False)
# ops
lnbits_data_folder: str = Field(default="./data")
@ -136,7 +137,6 @@ class Settings(BaseSettings):
"lnbits_admin_users",
"lnbits_allowed_users",
"lnbits_theme_options",
# "lnbits_ad_space",
"lnbits_admin_extensions",
"lnbits_disabled_extensions",
"lnbits_allowed_funding_sources",