[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Debconf-discuss] [Debconf-announce] DebConf15: Call for keys for keysigning in Heidelberg, Germany



On Sat, 01 Aug 2015, Aníbal Monsalve Salazar wrote:
> If you have a laptop/tablet/phone you could convert the list (after
> checking the hash) into a html file with a form.
> 
> Joey Hess did just that. Please have a look at his program and
> instructions available at:
> 
> http://lists.debconf.org/lurker/message/20140821.071738.a6aa8691.en.html
> http://lists.debconf.org/lurker/message/20140824.033904.d828143b.en.html
> 
> Please share in this list your improvements to Joey's program. ;)

Here's something simple that seems to work:

1. Fix Joey Hess' script to output html that seems to be better
tolerated by some tools (attached)

2. You should change the number of columns at the top of the script to
something that suits your device (I used 2, it was originally 12).

3. Create the HTML using the haskell script.  Do not do the UTF8 iconv
step, the dc15 ksp text file is already in UTF8.  Modify the HTML in a
text editor if you want to add sha information, etc.

4. Use firefox to fill the form, and SAVE TO PDF to record it.  Worked
on my old android device just fine.   Test it a bit to ensure it works,
just in case.

The saved PDF should have the checkboxes filled (test it to ensure it
works!).  You will need to OCR it later or manually process that PDF,
just like if you had used paper.

Alternatively, write a consumer for Joey Hess form and feed it to caff
to skip the OCR/manual process, if you're feeling like it ;-)

Futher corrections to the script and procedure are quite welcome!

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
import Text.Parsec
import Text.Parsec.String
import Data.Either
import Data.List
import Control.Applicative hiding (many, (<|>))

numcols :: Int
numcols = 2

main :: IO ()
main = interact $ either (error . show) format . parse keys "input"

data Key = Key
	{ knum :: Int
	, kname :: String
	, kdetails :: [String]
	}

keys :: Parser [Key]
keys = do
	ls <- instructionlines
	many $ Key <$> getnum <*> getname <*> getdetails

instructionlines :: Parser [String]
instructionlines = restOfLine `manyTill` try (string "\n\n\n")

restOfLine :: Parser String
restOfLine = anyChar `manyTill` try newline

getnum :: Parser Int
getnum = read <$> between (char '#') (many1 space) (many1 digit)

getname :: Parser String
getname = manyTill anyChar
	(try (void (string "(rank:" >> restOfLine) <|> void newline))

getdetails :: Parser [String]
getdetails = restOfLine `manyTill` try (void (string "\n\n") <|> eof)

void :: Parser a -> Parser ()
void p = p >> return ()

format :: [Key] -> String
format l = unlines $ concat
	[ header
	, intercalate chunksep (map (map formatkey) (segment l))
	, footer
	]
  where
	header= [ "<html><head><meta charset=\"utf8\"><meta name=\"DebConf KSP\"></head>"
		, "<body>"
		, "SHA256 Checksum: "
		, "<form method=get action=http://localhost/saveme>"
		, "<table>"
		, "<tr>"
		]
	footer = 
		[ "</tr>"
		, "</table>"
		, "<input type=submit value=Save>"
		, "</form>"
		, "</body></html>"
		]
	chunksep = ["</tr>", "<tr>"]

	formatkey k = concat
		[ "<td>"
		, '#' : show (knum k)
		, "<label><input type=checkbox name=" ++ show (knum k) ++ ">"
		, kname k
		-- TODO: allow expanding to see kdetails k
		, "</input></label></td>"
		]
	
	segment [] = []
	segment l = 
		let (chunk, rest) = splitAt numcols l
		in chunk : segment rest

Reply to: