import Control.Arrow.ArrowIO
import Control.Arrow.ArrowIf
import Control.Arrow.ArrowList
+import Control.Monad.Trans
import Data.Char
import Data.Maybe
import Network.HTTP.Lucu
import Rakka.SystemConfig
import Rakka.Wiki.Engine
import System.FilePath
+import Text.XML.HXT.Arrow.WriteDocument
import Text.XML.HXT.Arrow.XmlArrow
+import Text.XML.HXT.Arrow.XmlIOStateArrow
import Text.XML.HXT.Arrow.XmlNodeSet
import Text.XML.HXT.DOM.TypeDefs
+import Text.XML.HXT.DOM.XmlKeywords
fallbackPageEntity :: Environment -> [String] -> IO (Maybe ResourceDef)
{-
HTTP/1.1 302 Found
- Location: http://example.org/Destination#Redirect:Source
+ Location: http://example.org/Destination.html#Redirect:Source
-}
handleRedirect :: (ArrowXml a, ArrowIO a) => Environment -> a Page (Resource ())
handleRedirect env
= proc redir
- -> do BaseURI baseURI <- getSysConfA (envSysConf env) -< ()
- returnA -< redirect Found (mkPageURI baseURI $ redirDest redir) -- FIXME
+ -> returnA -< do mType <- getEntityType
+ case mType of
+ MIMEType "application" "xhtml+xml" _
+ -> do BaseURI baseURI <- getSysConf (envSysConf env)
+ let uri = mkPageFragmentURI
+ baseURI
+ (redirDest redir)
+ ("Redirect:" ++ redirName redir)
+ redirect Found uri
+
+ MIMEType "text" "xml" _
+ -> do setContentType mType
+ [resultStr] <- liftIO $ runX ( setErrorMsgHandler False fail
+ >>>
+ constA redir
+ >>>
+ xmlizePage
+ >>>
+ writeDocumentToString [ (a_indent, v_1) ]
+ )
+ output resultStr
+
+ _ -> fail ("internal error: getEntityType returned " ++ show mType)
handleGetEntity :: (ArrowXml a, ArrowChoice a, ArrowIO a) => Environment -> a Page (Resource ())
bottom: 1em;
right: 1em;
}
+
+/* redirection message ********************************************************/
+.redirection {
+ margin: 5px;
+ padding: 2px;
+
+ font-size: 80%;
+
+ background-color: #fafafa;
+ color: #888888;
+
+ border-color: #eeeeee;
+ border-width: 1px;
+ border-style: dotted
+}
+
+.redirection input[type="button"] {
+ background-color: inherit;
+
+ color: #008800;
+
+ border-width: 0;
+}
+
+.redirection input[type="button"]:hover {
+ color: #880000;
+}
</textData>
</page>
--- /dev/null
+$(document).ready(function () {
+ var fragment;
+
+ if ($.browser.mozilla) {
+ fragment = window.location.hash; // 何故か勝手に URI デコードされる
+ }
+ else {
+ fragment = decodeURIComponent(window.location.hash);
+ }
+
+ var m = fragment.match(/^#Redirect:(.*)$/);
+ if (m) {
+ var from = m[1];
+
+ var editButton
+ = $.INPUT({className: "editButton",
+ type: "button",
+ value: from,
+ title: "Edit the page"});
+ $(editButton).click(function () {
+ alert("not implemented");
+ });
+
+ var box
+ = $.P({className: "redirection"},
+ "This page is redirected from ", editButton, ".");
+
+ $("div.title").after(box);
+ }
+});
\ No newline at end of file