from urllib import quote

from pylons import c, g

from r2.lib.pages import Ads as BaseAds


class Ads(BaseAds):
    def __init__(self):
        BaseAds.__init__(self)

        url_key = "adzerk_https_url" if c.secure else "adzerk_url"
        site_name = getattr(c.site, "analytics_name", c.site.name)
        self.ad_url = g.config[url_key].format(
            subreddit=quote(site_name.lower()),
            origin=c.request_origin,
        )
        self.frame_id = "ad_main"

from urllib import quote

from pylons import c, g

from r2.lib.pages import Ads as BaseAds
from r2.models.subreddit import DefaultSR


class Ads(BaseAds):
    def __init__(self):
        BaseAds.__init__(self)

        url_key = "adzerk_https_url" if c.secure else "adzerk_url"
        site_name = getattr(c.site, "analytics_name", c.site.name)

        # adzerk reporting is easier when not using a space in the tag
        if isinstance(c.site, DefaultSR):
            site_name = "-reddit.com"

        self.ad_url = g.config[url_key].format(
            subreddit=quote(site_name.lower()),
            origin=c.request_origin,
        )
        self.frame_id = "ad_main"

Change frontpage keyword to "-reddit.com".
Change frontpage keyword to "-reddit.com".

  from urllib import quote
  
  from pylons import c, g
  
  from r2.lib.pages import Ads as BaseAds
+ from r2.models.subreddit import DefaultSR
  
  
  class Ads(BaseAds):
      def __init__(self):
          BaseAds.__init__(self)
  
          url_key = "adzerk_https_url" if c.secure else "adzerk_url"
          site_name = getattr(c.site, "analytics_name", c.site.name)
+ 
+         # adzerk reporting is easier when not using a space in the tag
+         if isinstance(c.site, DefaultSR):
+             site_name = "-reddit.com"
+ 
          self.ad_url = g.config[url_key].format(
              subreddit=quote(site_name.lower()),
              origin=c.request_origin,
          )
          self.frame_id = "ad_main"
  
Change frontpage keyword to "-reddit.com".
## Code Before:
from urllib import quote

from pylons import c, g

from r2.lib.pages import Ads as BaseAds


class Ads(BaseAds):
    def __init__(self):
        BaseAds.__init__(self)

        url_key = "adzerk_https_url" if c.secure else "adzerk_url"
        site_name = getattr(c.site, "analytics_name", c.site.name)
        self.ad_url = g.config[url_key].format(
            subreddit=quote(site_name.lower()),
            origin=c.request_origin,
        )
        self.frame_id = "ad_main"

## Instruction:
Change frontpage keyword to "-reddit.com".
## Code After:
from urllib import quote

from pylons import c, g

from r2.lib.pages import Ads as BaseAds
from r2.models.subreddit import DefaultSR


class Ads(BaseAds):
    def __init__(self):
        BaseAds.__init__(self)

        url_key = "adzerk_https_url" if c.secure else "adzerk_url"
        site_name = getattr(c.site, "analytics_name", c.site.name)

        # adzerk reporting is easier when not using a space in the tag
        if isinstance(c.site, DefaultSR):
            site_name = "-reddit.com"

        self.ad_url = g.config[url_key].format(
            subreddit=quote(site_name.lower()),
            origin=c.request_origin,
        )
        self.frame_id = "ad_main"
