about summary refs log tree commit diff stats
path: root/arc/load.arc
blob: b9037aa4d605fe7affc5e39191ff5b31b8b1fb5c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
; support for dividing arc files into sections of different level, and
; selectively loading just sections at or less than a given level

; usage:
;   load.arc [level] [arc files] -- [mu files]

(def selective-load (file (o level 999))
;?   (prn "loading @file at level @level")
  (fromfile file
    (whilet expr (read)
;?       (prn car.expr)
      (if (is 'section expr.0)
        (when (<= expr.1 level)
          (each x (cut expr 2)
            (eval x)))
        (eval expr))
;?       (prn car.expr " done")
      )))

(= section-level 999)
(point break
(each x (map [fromstring _ (read)] cdr.argv)
  (if (isa x 'int)
        (= section-level x)
      (is '-- x)
        (break)  ; later args are mu files
      :else
        (selective-load string.x section-level))))
ng.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* 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

namespace dokuwiki\Action;

use dokuwiki\Action\Exception\FatalException;

/**
 * Class Sitemap
 *
 * Generate an XML sitemap for search engines. Do not confuse with Index
 *
 * @package dokuwiki\Action
 */
class Sitemap extends AbstractAction {

    /** @inheritdoc */
    public function minimumPermission() {
        return AUTH_NONE;
    }

    /**
     * Handle sitemap delivery
     *
     * @author Michael Hamann <michael@content-space.de>
     * @throws FatalException
     * @inheritdoc
     */
    public function preProcess() {
        global $conf;

        if($conf['sitemap'] < 1 || !is_numeric($conf['sitemap'])) {
            throw new FatalException(404, 'Sitemap generation is disabled');
        }

        $sitemap = \Sitemapper::getFilePath();
        if(\Sitemapper::sitemapIsCompressed()) {
            $mime = 'application/x-gzip';
        } else {
            $mime = 'application/xml; charset=utf-8';
        }

        // Check if sitemap file exists, otherwise create it
        if(!is_readable($sitemap)) {
            \Sitemapper::generate();
        }

        if(is_readable($sitemap)) {
            // Send headers
            header('Content-Type: ' . $mime);
            header('Content-Disposition: attachment; filename=' . utf8_basename($sitemap));

            http_conditionalRequest(filemtime($sitemap));

            // Send file
            //use x-sendfile header to pass the delivery to compatible webservers
            http_sendfile($sitemap);

            readfile($sitemap);
            exit;
        }

        throw new FatalException(500, 'Could not read the sitemap file - bad permissions?');
    }

}