Ejemplo n.º 1
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function articles()
 {
     $feeds = $this->feedBusinessLayer->findAll($this->userId);
     $items = $this->itemBusinessLayer->getUnreadOrStarred($this->userId);
     // build assoc array for fast access
     $feedsDict = array();
     foreach ($feeds as $feed) {
         $feedsDict['feed' . $feed->getId()] = $feed;
     }
     $articles = array();
     foreach ($items as $item) {
         array_push($articles, $item->toExport($feedsDict));
     }
     $response = new JSONResponse($articles);
     $response->addHeader('Content-Disposition', 'attachment; filename="articles.json"');
     return $response;
 }
Ejemplo n.º 2
0
    /**
     * @NoCSRFRequired
     * @PublicPage
     *
     * Generates a web app manifest, according to specs in:
     * https://developer.mozilla.org/en-US/Apps/Build/Manifest
     */
    public function manifest() {
        $config = $this->appConfig->getConfig();

        // size of the icons: 128x128 is required by FxOS for all app manifests
        $iconSizes = ['128', '512'];
        $icons = [];

        $locale = str_replace('_', '-', $this->l10n->getLanguageCode());

        foreach ($iconSizes as $size) {
            $filename = 'app-' . $size . '.png';
            if (file_exists(__DIR__ . '/../img/' . $filename)) {
                $icons[$size] = $this->urlGenerator->imagePath($config['id'],
                    $filename);
            }
        }


        $data = [
            "name" => $config['name'],
            "type" => 'web',
            "default_locale" => $locale,
            "description" => $config['description'],
            "launch_path" => $this->urlGenerator->linkToRoute(
                $config['navigation']['route']),
            "icons" => $icons,
            "developer" => [
                "name" => $config['author'],
                "url" => $config['homepage']
            ]
        ];

        $response = new JSONResponse($data);
        $response->addHeader('Content-Type',
            'application/x-web-app-manifest+json');

        return $response;
    }