summaryrefslogtreecommitdiffstats
path: root/.github/no-response.yml
blob: d745b86385e2f82bb6f3520f87d6e51e5fc7dccd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
# Configuration for probot-no-response - https://github.com/probot/no-response

# Number of days of inactivity before an Issue is closed for lack of response
daysUntilClose: 14
# Label requiring a response
responseRequiredLabel: needs info
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
closeComment: >
  This issue has been automatically closed because there has been no response
  to our request for more information from the original author. With only the
  information that is currently in the issue, we don't have enough information
  to take action. Please reach out if you have or find the answers we need so
  that we can investigate further.
f0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<?php
/**
 * ownCloud - News
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Alessandro Cosentino <cosenal@gmail.com>
 * @author Bernhard Posselt <dev@bernhard-posselt.com>
 * @copyright Alessandro Cosentino 2012
 * @copyright Bernhard Posselt 2012, 2014
 */

namespace OCA\News\ArticleEnhancer;


class Enhancer {

    private $enhancers = [];
    private $globalEnhancers = [];

    /**
     * @param string $feedUrl
     * @param ArticleEnhancer $enhancer
     */
    public function registerEnhancer($feedUrl, ArticleEnhancer $enhancer){
        $feedUrl = $this->removeTrailingSlash($feedUrl);

        // create hashkeys for all supported protocols for quick access
        $this->enhancers[$feedUrl] = $enhancer;
        $this->enhancers['https://' . $feedUrl] = $enhancer;
        $this->enhancers['http://' . $feedUrl] = $enhancer;
        $this->enhancers['https://www.' . $feedUrl] = $enhancer;
        $this->enhancers['http://www.' . $feedUrl] = $enhancer;
    }


    /**
     * Registers enhancers that are run for every item and after all previous
     * enhancers have been run
     * @param ArticleEnhancer $enhancer
     */
    public function registerGlobalEnhancer (ArticleEnhancer $enhancer) {
        $this->globalEnhancers[] = $enhancer;
    }


    /**
     * @param \OCA\News\Db\Item $item
     * @param string $feedUrl
     * @return \OCA\News\Db\Item enhanced item
     */
    public function enhance($item, $feedUrl){
        $feedUrl = $this->removeTrailingSlash($feedUrl);

        if(array_key_exists($feedUrl, $this->enhancers)) {
            $result = $this->enhancers[$feedUrl]->enhance($item);
        } else {
            $result = $item;
        }

        foreach ($this->globalEnhancers as $enhancer) {
            $result = $enhancer->enhance($result);
        }

        return $result;
    }


    /**
     * @param string $url
     * @return string
     */
    private function removeTrailingSlash($url) {
        if($url[strlen($url)-1] === '/') {
            return substr($url, 0, -1);
        } else {
            return $url;
        }
    }


}