[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [donate/master] Fixed Twitter card on cryptocurrency page
commit f22cd767f063fcc9a6b74b38306a2a14257bd6d8
Author: peterh <peterh@xxxxxxxxxxxxxxx>
Date: Mon Mar 18 16:33:48 2019 -0700
Fixed Twitter card on cryptocurrency page
It wasn't working because it needed to have baseUrl set in the template
vars. I made this a universal template variable. Also the cryptocurrency
page and the main donate page were using the same meta tags, so I made
it so they can be shared.
Issue #40049
---
src/BaseController.php | 1 -
src/DonateController.php | 5 -----
src/dependencies.php | 6 +++++-
templates/cryptocurrency.twig | 12 +-----------
templates/default-meta-tags.twig | 11 +++++++++++
templates/index.twig | 12 +-----------
6 files changed, 18 insertions(+), 29 deletions(-)
diff --git a/src/BaseController.php b/src/BaseController.php
index b9fde672..5382dd35 100644
--- a/src/BaseController.php
+++ b/src/BaseController.php
@@ -16,5 +16,4 @@ class BaseController {
$this->renderer = $container->get('renderer');
$this->router = $container->get('router');
}
-
}
diff --git a/src/DonateController.php b/src/DonateController.php
index 20516c43..c3664e8d 100644
--- a/src/DonateController.php
+++ b/src/DonateController.php
@@ -11,17 +11,12 @@ class DonateController extends BaseController {
public function index($request, $response, $args) {
$campaignController = new CampaignController($this->container);
- $uri = $request->getUri();
- $baseUrl = $uri->getBaseUrl();
- $path = $uri->getPath();
$now = $this->environment_info->now();
-
$templateToRender = 'index.twig';
$config = PPConfigManager::getConfigWithDefaults();
$stripeConfig = StripeConfig::setup();
$this->vars = array(
- 'baseUrl' => $baseUrl,
'environmentName' => $this->environment_info->name(),
'isMatchingDonation' => $this->is_matching_donation($now),
'paypalMerchantId' => $config['acct1.MerchantID'],
diff --git a/src/dependencies.php b/src/dependencies.php
index c7e1f6c0..d7a6fa8e 100644
--- a/src/dependencies.php
+++ b/src/dependencies.php
@@ -16,11 +16,15 @@ $container['renderer'] = function ($container) {
$view = new \Slim\Views\Twig($settings['template_path'], [
'cache' => $cache,
]);
+ $request = $container['request'];
$view->addExtension(new \Slim\Views\TwigExtension(
$container['router'],
- $container['request']->getUri()
+ $request->getUri()
));
+ $baseUrl = $request->getUri()->getBaseUrl();
+ $view->offsetSet('baseUrl', $baseUrl);
+
// load i18n twig extension
$view->addExtension(new Twig_Extensions_Extension_I18n());
diff --git a/templates/cryptocurrency.twig b/templates/cryptocurrency.twig
index d61f1ddf..4a00b91c 100644
--- a/templates/cryptocurrency.twig
+++ b/templates/cryptocurrency.twig
@@ -5,17 +5,7 @@
{% endblock %}
{% block head %}
- <meta property="og:url" content="{{ baseUrl }}" />
- <meta property="og:type" content="article" />
- <meta property="og:title" content="{% trans %}Tor: Strength in Numbers{% endtrans %}" />
- <meta property="og:description" content="{% trans %}Donate to the Tor Project and protect the privacy of millions.{% endtrans %} {% trans %}Anonymity loves company.{% endtrans %}" />
- <meta property="og:image" content="{{ baseUrl }}/images/og-image-strength-in-numbers.png" />
-
- <meta name="twitter:card" content="{% trans %}summary_large_image{% endtrans %}" />
- <meta name="twitter:site" content="{% trans %}@torproject{% endtrans %}" />
- <meta name="twitter:title" content="{% trans %}Tor: Strength in Numbers{% endtrans %}" />
- <meta name="twitter:description" content="{% trans %}Donate to the Tor Project and protect the privacy of millions.{% endtrans %} {% trans %}Anonymity loves company.{% endtrans %}" />
- <meta name="twitter:image" content="{{ baseUrl }}/images/og-image-strength-in-numbers.png" />
+ {% include 'default-meta-tags.twig' %}
{% endblock %}
{% block header %}
diff --git a/templates/default-meta-tags.twig b/templates/default-meta-tags.twig
new file mode 100644
index 00000000..9a4d0c75
--- /dev/null
+++ b/templates/default-meta-tags.twig
@@ -0,0 +1,11 @@
+ <meta property="og:url" content="{{ baseUrl }}" />
+ <meta property="og:type" content="article" />
+ <meta property="og:title" content="{% trans %}Tor: Strength in Numbers{% endtrans %}" />
+ <meta property="og:description" content="{% trans %}Donate to the Tor Project and protect the privacy of millions.{% endtrans %} {% trans %}Anonymity loves company.{% endtrans %}" />
+ <meta property="og:image" content="{{ baseUrl }}/images/og-image-strength-in-numbers.png" />
+
+ <meta name="twitter:card" content="{% trans %}summary_large_image{% endtrans %}" />
+ <meta name="twitter:site" content="{% trans %}@torproject{% endtrans %}" />
+ <meta name="twitter:title" content="{% trans %}Tor: Strength in Numbers{% endtrans %}" />
+ <meta name="twitter:description" content="{% trans %}Donate to the Tor Project and protect the privacy of millions.{% endtrans %} {% trans %}Anonymity loves company.{% endtrans %}" />
+ <meta name="twitter:image" content="{{ baseUrl }}/images/og-image-strength-in-numbers.png" />
diff --git a/templates/index.twig b/templates/index.twig
index fac43775..18e75cfc 100644
--- a/templates/index.twig
+++ b/templates/index.twig
@@ -5,17 +5,7 @@
{% endblock %}
{% block head %}
- <meta property="og:url" content="{{ baseUrl }}" />
- <meta property="og:type" content="article" />
- <meta property="og:title" content="{% trans %}Tor: Strength in Numbers{% endtrans %}" />
- <meta property="og:description" content="{% trans %}Donate to the Tor Project and protect the privacy of millions.{% endtrans %} {% trans %}Anonymity loves company.{% endtrans %}" />
- <meta property="og:image" content="{{ baseUrl }}/images/og-image-strength-in-numbers.png" />
-
- <meta name="twitter:card" content="{% trans %}summary_large_image{% endtrans %}" />
- <meta name="twitter:site" content="{% trans %}@torproject{% endtrans %}" />
- <meta name="twitter:title" content="{% trans %}Tor: Strength in Numbers{% endtrans %}" />
- <meta name="twitter:description" content="{% trans %}Donate to the Tor Project and protect the privacy of millions.{% endtrans %} {% trans %}Anonymity loves company.{% endtrans %}" />
- <meta name="twitter:image" content="{{ baseUrl }}/images/og-image-strength-in-numbers.png" />
+ {% include 'default-meta-tags.twig' %}
{% endblock %}
{% block header %}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits