~alcinnz/rhapsode

943ea735e8cc446f1ec30f515d8d3e0465a47b69 — Adrian Cochrane 4 years ago 0a65b2c
Upload Types modules, & useragent stylesheet with audio cues.

Prevent websites (and userstyles) from overriding the link audio cue.
5 files changed, 114 insertions(+), 0 deletions(-)

M bulletpoint.wav
A link.oga
D link.wav
A src/Types.hs
A useragent.css
M bulletpoint.wav => bulletpoint.wav +0 -0
A link.oga => link.oga +0 -0
D link.wav => link.wav +0 -0
A src/Types.hs => src/Types.hs +37 -0
@@ 0,0 1,37 @@
{-# LANGUAGE OverloadedStrings #-}
module Types(CArray, Page(..)) where

import System.Directory (getCurrentDirectory) -- default referer URI
import StyleTree (StyleTree)
import Data.CSS.Preprocessor.Conditions (ConditionalStyles, conditionalStyles)
import Text.XML
import qualified Data.Map.Strict as M
import Network.URI

import Foreign.Ptr
import Foreign.StablePtr

type CArray a = Ptr a

data Page = Page {url :: URI, css :: ConditionalStyles StyleTree, html :: Document}

foreign export ccall c_initialReferer :: IO (StablePtr Page)

c_initialReferer = do
    cwd <- getCurrentDirectory
    newStablePtr $ Page {
        -- Default to URIs being relative to CWD.
        url = URI {uriScheme = "file:", uriPath = cwd,
            uriAuthority = Nothing, uriQuery = "", uriFragment = ""},
        -- Blank values:
        css = conditionalStyles nullURI "temp",
        html = Document {
            documentPrologue = Prologue [] Nothing [],
            documentRoot = Element "temp" M.empty [],
            documentEpilogue = []
        }
    }

foreign export ccall c_freePage :: StablePtr Page -> IO ()

c_freePage = freeStablePtr

A useragent.css => useragent.css +77 -0
@@ 0,0 1,77 @@
head, link, meta, style, script, title, base {speak: never}
datalist, template {speak: never}
html {speak-as: normal no-punctuation}

/** Forms **/
button, select, textarea, input, output {speak: never} /* Leave to special form entry mode */
button[type=submit] {speak: always}
input[type=submit][value] {speak: always; content: attr(value)}

/** Tables **/
table::before {content: 'Table'; voice-volume: x-soft}
tr {cue-before: url(about:bulletpoint.wav);}
td, th {cue-before: url(about:bulletpoint.wav) -1db;}
/* TODO Do we actually want this feature, would take significant processing. */
th > :th /* Rhapsode-specific, selects inlined table headers */ {speak: never;}
table caption {voice-volume: soft}

/** Sectioning **/
footer, header {voice-volume: soft}
nav {speak: never} /* Expose the links for navigation, but not narration */
h1, h2, h3, h4, h5, h6, legend, th, summary, dt {voice-stress: strong}
h1 {pause: x-strong; voice-rate: x-slow}
h2 {pause: strong; voice-rate: slow}
h3, th, summary, legend, dt {pause: medium; voice-rate: medium}
h4 {pause: weak; voice-rate: fast}
h5, h6 {pause: x-weak; voice-rate: fast}
h6 {voice-pitch: high}

/** Text **/
hr {pause: x-strong}
p, pre, samp, blockquote {pause: strong}
pre, address, samp {speak-as: literal-punctuation}
pre, samp, code {voice: neutral 2}
[href], :link {cue-before: url(link.oga) !important; voice-pitch: low}
:link:visited {cue-before: url(link.oga) -1db !important}
img {voice-volume: soft; content: attr(src)}
img[alt] {content: attr(alt)}

b, strong {voice-rate: slow}
i, em {voice-stress: strong}
br {pause: medium}
code {speak-as: literal-punctuation}
s, del {voice-volume: x-soft}
u, ins {voice-volume: loud}

/** lists **/
li, dt, dd {cue-before: url(about:bulletpoint.wav); pause: strong}
li::before, dt::before, dd::before {content: 'd'} /* Since the cue-before isn't coming accross */
li li, dd dt, dd dd {cue-before: url(about:bulletpoint.wav) -1db}
li li li, dd dd dt, dd dd dd {cue-before: url(about:bulletpoint.wav) -2db}
li li li li, dd dd dd dt, dd dd dd dd {cue-before: url(about:bulletpoint.wav) -3db}
li li li li li, dd dd dd dd dt, dd dd dd dd dd {
    cue-before: url(about:bulletpoint.wav) -4db
}
li li li li li li, dd dd dd dd dd dt, dd dd dd dd dd dd {
    cue-before: url(about:bulletpoint.wav) -5db
}

ol {counter-reset: -rhaps-ol}
ol li::before {
    counter-increment: -rhaps-ol;
    content: counters(-rhaps-ol, ' ')
}

/** HTML5 **/
abbr[title]::after {content: attr(title); voice-volume: x-soft}
abbr {speak-as: spell-out}

q, blockquote {voice-family: female 2}
cite {voice-stress: reduce}
dialog {speak: never} dialog[open] {speak: always}
kbd {speak-as: spell-out}
progress {content: attr(value) ' of ' attr(max)}
sub {voice-rate: x-fast}
sup {voice-rate: fast}
var {voice-rate: slow}
aside {voice-volume: soft}