2

I have a large pile of lecture notes in raw HTML format. I would like to add interactive content to these notes, in particular incorporating online exercises. I have some experience implementing online exercises as cgi-bin executables compiled from Haskell code running on the server, interacting with a student record file and sending suitable HTML back to the browser, using Text.Xhtml to generate the content. Now I plan to integrate the notes and the exercises.

The trouble is that I don't want to spend ages manually transforming my raw HTML into Haskell code to generate exactly the raw HTML I started with. Instead, I'd like to put my Haskell code and my HTML in the same source file, with placeholders in the latter for content generated by the former. A suitable tool should then transform this file into Haskell source code for (e.g.) a cgi-bin executable which generates the corresponding page.

Before I go hacking up such a piece of kit, I thought I'd ask if there's better technology out there already. The fixed points are the large legacy lump of HTML, the need to implement the assessment of the exercises in Haskell, and the need to interact with student records on the server. The handicap is that I need to use the departmental web server and I can't reconfigure it (ok, maybe I could ask nicely): that's one of the reasons I currently use cgi-bin executables, which are just fine on our server already, but I'm open to other possibilities.

My current plan is to write a (I mean adapt an existing) preprocessor to support a special syntax for defining functions of type

Html -> ... -> Html -> Html

that looks a lot like raw HTML with splice points. Then what I do with my existing raw HTML is indent it a bit and mark the holes.

But would that be a waste of time? Please, please tell me that this question is a duplicate!

4

3 回答 3

3

有像 Yesod 和 Happstack 这样的 Haskell 框架,它们使用你描述的模板引擎。

您是否查看过http://www.haskell.org/haskellwiki/HSPhttp://www.haskell.org/haskellwiki/Web/Libraries/Templating上的 haskell wiki ?

他们可能会做你需要的。

于 2012-09-06T10:09:18.550 回答
0

我有一大堆原始 HTML 格式的讲义。我想在这些笔记中添加互动内容,特别是结合在线练习。

已经有一个用 Haskell 编写的系统(称为“ActiveHs”),允许将讲义和交互式练习放在一个文件中。

见: http:
//pnyf.inf.elte.hu/fp/UsersGuide_en.xml
http://pnyf.inf.elte.hu/fp/Constructive_en.xml

我真的可以说它的代码写得非常好并且完全开源!

于 2012-09-12T03:27:44.860 回答
0

你可能会在这里找到一些可以完成工作的东西:Templating packages for Haskell

您可能应该考虑使用 Snap、Yesod 或 Happstack 来提供内容。

于 2012-09-06T10:13:30.397 回答