简体   繁体   English

iBooks小部件:参数和共享资产

[英]iBooks Widgets: Parameters and shared assets

Consider a text book made with iBooks Author, using HTML widgets for interactive features, for example a quiz at the end of every chapter. 考虑一本由iBooks Author制作的教科书,该教科书使用具有交互功能的HTML小部件,例如,每章末尾的测验。 You end up with a lot of widgets (one per chapter) that share a lot of assets (image files, javascript libraries). 最后,您会得到许多共享许多资产(图像文件,javascript库)的小部件(每章一个)。

Casual use of iBooks Author seems to indicate that every widget is its own independent bundle that gets copied into the book. 随意使用iBooks Author似乎表明每个小部件都是其自己的独立捆绑包,该捆绑包被复制到书中。 This would be horribly wasteful in this scenario. 在这种情况下,这将是非常浪费的。

  1. Can I include the same bundle multiple times (so that is appears in many locations, but does not take up redundant disk space)? 我可以多次包含同一个包吗(这样会出现在很多位置,但不会占用冗余磁盘空间)?

  2. Can I pass parameters to the widget (so that I can tell it which chapter's data to display)? 我可以将参数传递给窗口小部件(以便我可以告诉它显示哪个章节的数据)吗?

  3. If 1+2 don't work, can a widget refer to assets stored in a shared location somewhere else in the same book (so that I can produce fifty lean widgets that don't have to contain images and Javascript themselves)? 如果1 + 2不起作用,那么小部件可以引用存储在同一本书中其他位置的共享位置中的资产吗(这样我就可以生成五十个不必包含图像和Javascript本身的精益小部件)?

Just have an answer for 3., still trying to figure out the other two. 只需给出3的答案,仍在尝试找出另外两个。

The ibooks file created by IBA is basically an EPUB document. 由IBA创建的ibooks文件基本上是EPUB文档。 Because this is the case, you can refer to files within the package itself with HTML from your widgets. 因为是这种情况,所以您可以使用窗口小部件中的HTML引用包本身中的文件。

IBA creates an assets folder where it stores all the images, widgets, and other items. IBA创建一个assets文件夹,在其中存储所有图像,小部件和其他项目。

For example, <img src='../../images/image.jpg' /> in the HTML in your widget will display image.jpg . 例如,小部件中HTML中的<img src='../../images/image.jpg' />将显示image.jpg

To see and add images, js, whatever to the iBook after it is generated, unzip your iBooks file. 要在生成iBook之后查看并添加图像,js,并将其添加到iBook,请unzip iBooks文件。

  1. You can include the same bundle multiple times, but I believe it doesn't share all the assets so each copy takes up space. 您可以多次包含相同的包,但我相信它不会共享所有资产,因此每个副本都占用空间。
  2. You can't pass parameters to the widget as far as I can tell. 据我所知,您无法将参数传递给小部件。 I wrote this somewhere else, too, but we built a quiz widget that was at the end of each chapter and we ended up just cloning code for the widget and setting all the variables via JSON. 我也是在其他地方写的,但是我们在每一章的末尾构建了一个测验小部件,最终只为该小部件克隆了代码,并通过JSON设置了所有变量。 That turned out to be the easiest way. 原来那是最简单的方法。
  3. localstorage is shared between all the widgets, so you can store shared information there (base-64 encode the images?). localstorage在所有小部件之间共享,因此您可以在其中存储共享信息(base-64编码图像?)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM