Coder Social home page Coder Social logo

bocharsky-bw / stand-with-ukraine-bundle Goto Github PK

View Code? Open in Web Editor NEW
23.0 3.0 7.0 250 KB

A Symfony bundle that provides #StandWithUkraine banner and has some built-in features to block access to your resource for Russian-speaking users.

Home Page: https://stand-with-ukraine.pp.ua/

License: MIT License

PHP 83.30% Twig 16.70%
bundle standwithukraine banner symfony-bundle stopwar ukraine

stand-with-ukraine-bundle's Introduction

StandWithUkraineBundle

Stand With Ukraine

CI

На русском? Смотри README.ru.md

This bundle provides a built-in StandWithUkraine banner for your Symfony application and has some features to block content for Russian-speaking users. Why? Great question! There is a war in Ukraine right now. You can read more about it here.

The initial idea of this bundle is to push Russian-speaking people to think! Almost all Russian media are not independent anymore and spread fake news to their users about what is happening in the world and even in their own country. Everybody has a choice. You can choose different sources in different languages to read the news from many other independent and trusted media around the world, don't limit yourself with Russian language and Russian media only.

Features

Some features included in this bundle:

  • Display "StandWithUkraine" banner to show that your website stands united with the people of Ukraine. Example of StandWithUkraine banner
  • Block content for users who have the preferred language in Accept-Language request header set to ru. Basically, affects people who read most of the content in Russian language. Users would be able to access the content only after changing their preferred language to any other language. They still can keep Russian language, but as a secondary one. Example of access denied page
  • Block content for users who are trying to get access from Russian IP addresses, i.e. accessing the content from Russia. Users would be able to access the content only after connecting via a VPN client choosing a location different from Russia region there. It makes things less convenient probably, but if you're using a good VPN client - you get better security, especially if you're connecting from public Wi-Fi spots or do not trust your internet provider. Example of access denied page

Installation

Install with Composer:

$ symfony composer require bw/stand-with-ukraine-bundle

Then, enable the bundle if you don't use Symfony Flex:

// config/bundles.php

return [
    // ...
    BW\StandWithUkraineBundle\StandWithUkraineBundle::class => ['all' => true],
];

And then activate/deactivate event subscribers in its configuration.

Configuration

Configuration is optional, all options have defaults. But if you want to change it - create a config file config/services/stand_with_ukraine.yaml and tweak it. Below you can find the full configuration example with the default values:

# config/packages/stand_with_ukraine.yaml

stand_with_ukraine:
    banner:
        enabled:              true

        # Possition of the banner: "top" or "bottom"
        position:             top

        # Wrap the banner with a link to the given URL
        target_url:           null

        # Will be shown in the banner, HTTP host by default
        brand_name:           null
    ban_language:
        enabled:              true
        use_links:            true
    ban_country:
        enabled:              true
        use_links:            true

Or you can see it in your terminal, just run:

$ symfony console config:dump-reference stand_with_ukraine

Testing

For testing purposes, you can easily simulate bad requests to test things manually on your website in an easy way. To overwrite the actual country code with ru, use swu_overwrite_country_code_ru query parameter, i.e:

https://127.0.0.1:8000/?swu_overwrite_country_code_ru=yes

Also, you can overwrite preferred language with ru as well, use swu_overwrite_preferred_lang_ru query parameter, i.e:

https://127.0.0.1:8000/?swu_overwrite_preferred_lang_ru=yes

The system will thinks that you're sending requests from a Russian IP address or with Russian preferred language correspondingly and behave accordingly your configuration.

That's it!

Thanks for using this bundle! Feel free to create an issue or send a PR if you have any ideas how to improve it. And if you like it - please, share!

stand-with-ukraine-bundle's People

Contributors

bocharsky-bw avatar sergiy-petrov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stand-with-ukraine-bundle's Issues

What is this?

Where are we living? Our children have no choice? They will be flee, you want this? Then I will tell my opinion on this matter you are doing most wrong in your life.

Change event subscriber priorities

The priority of subscribers might be too aggressive. We have 13 and 14 for them which are too close to the system's
15 | "Symfony\Component\HttpKernel\EventListener\LocaleAwareListener::onKernelRequest(RequestEvent $event): void". There's literally no space between ours CountrySubscriber and system's LocaleAwareListener. We need to get lower those priorities. It just should be greater than the default's 0 priority at least, but making them higher will mean less code from other listeners will be executed for blocked requests. Let's use 11 and 12, it should leave enough space up to the system's LocaleAwareListener, but also high enough to get ahead of lower listeners

Heroku site is down

I suppose that's because there's no free plan there anymore. Consider moving whatever it was hosting to a static GH Pages based website and dropping the link from the repo frontpage sidebar?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.