EzDevInfo.com

Monocle

Optics library for Scala Monocle documentation - Home

Open Source Epub reader like Booki.sh

I want to create a epub reader for my website, So I need an open source solution for it. I found lots of things but I don't know what is the best one for me. Please help me. Recently I goto the https://booki.sh/library and it's prety cool. I'm looking for something like booki.sh epub reader.

Thanks


Source: (StackOverflow)

how to make next and previous button in monocle ebook reader using this codes?

I created this function for next and previous button, in other words there are 2 buttons in my html page and when i click next or previous the pages in the monocle will also move accordingly, i read that i have to use a custom page flipper for this but they have not provided an example of how to create one.

this is what i've tried and fails:

function fileSelected(event,str) {

    var thefile = document.getElementById('file');
    var tval = thefile.value;
    var ext = tval.split('.').pop();
    var files = event.target.files;
    var fname = tval.split(/(\\|\/)/g).pop();


   if (ext == "epub" || ext == "EPUB"){
        function createReader(bookData) {
            Monocle.Reader("reader", bookData);
        }
        new Epub(files[0], createReader);

   }else if(ext == "htm" || ext == "htm" || ext == "html" || ext == "HTML"){

        var bookData = {
            getComponents: function () {
                return [
                    fname
                    ];
            },
            getContents: function () {
                return [
                    {title: "test", src: fname}
                    ]
            },
            getComponent: function (componentId) {
                return {url:componentId};
            },
            getMetaData: function(key) {
                return {
                    title: "Test documents",
                    creator: "Aron Woost"
                    }[key];
            }
        }
                window.reader = Monocle.Reader('reader', bookData);

   }else{
        return false;
   }


}
function next(){    
    Monocle.Reader('reader', {}, {}, function (reader) {
      reader.moveTo({ direction: 1 });
    });
}

when clicking next will give an undefined error in my console.

any idea as how to implement a custom page flipper?

https://github.com/joseph/Monocle/wiki/Page-flippers

I am not that savvy in JS. sorry :(


Source: (StackOverflow)

Advertisements

Epub Reader Usage using Monocle

I need one conformation about using epub reader.how to give input as .epub file in monocle epub reader.I saw more samples in monocle github. But cannot identify which one will works.

I need to know about Monocle Epub reader below specifications :

 1. I have one .epub file

 2.how to read .epub using monocle epub reader 

i didn't get any solutions reading that.I saw monocle epub related link is :

https://github.com/joseph/Monocle#future-directions

I tries to below code :

<head>
  <!-- Include the Monocle library and styles -->
  <script src="scripts/monocore.js"></script>
  <link rel="stylesheet" type="text/css" rel='nofollow' href="styles/monocore.css" />
  <style>
    #reader { width: 300px; height: 400px; border: 1px solid #000; }
  </style>
</head>

<body>
  <!-- The reader element, with all content to paginate inside it -->
  <div id="reader">
    <h1>Hello world.</h1>
  </div>

  <!-- Instantiate the reader when the containing element has loaded -->
  <script>Monocle.Reader('reader');</script>
</body>

But can't get any idea about to give input file as epub file.

So can you please suggest me how to read .epub file using monocle epub redaer.It is very imaportant for me.or Is there any apis for epub readers for ios and android?

Thanks in advance.


Source: (StackOverflow)

pdf with 25mb size not readable in monocle reader

I just started using the monocle reader and tried using a pdf i downloaded before it has roughly 800 pages and 25mb file size, the problem now is that monocle returns with this error

TypeError: Cannot read property 'onFirstPageOfBook' of null

Resource interpreted as Document but transferred with MIME type application/pdf

If i use a 1 page pdf it works fine.

This is my code:

<script type="text/javascript">

    var bookData = {
        getComponents: function () {
            return [
                'coolresume.pdf',
                'content1.html'
                ];
        },
        getContents: function () {
            return [
                {title: "Chapter 1", src: 'coolresume.pdf'},
                {title: "Chapter 2", src: 'content1.html'}
                ]
        },
        getComponent: function (componentId) {
            return {url:componentId};
        },
        getMetaData: function(key) {
            return {
                title: "Test document",
                creator: "Aron Woost"
                }[key];
        }
    }

    Monocle.Events.listen(
        window,
        'load',
        function () {
            window.reader = Monocle.Reader('reader', bookData);
        }
    );
</script>

the monocle

This is were i got my sample PDF, this also works fine for when the same PDF is converted to EPUB

PDF URL


Source: (StackOverflow)

Monocle JS links trouble

Using Monocle.JS to render my EPUB book in Win Mobile 10 WebView. After adding Stencil component I noticed that pages are started to disappear from the book just after I clicked the link. Every even page became blank.
Also I noticed that even without adding Stencil control I could click my links using Magic panel.
Script behavior in this case is unpredictable - sometime I could see a linked page for a second and then another page (usually next one) appears. So could anyone share their experience with Stencil and navigating links in Monocle?
Maybe some ideas on how-to debug this issue? My environment is Windows 10 Mobile IE WebView running in simulator.

var readerOptions = {};
readerOptions.panels = Monocle.Panels.Magic; 
window.reader = Monocle.Reader('rdr', bookData, readerOptions, function(rdr) {
var scrubber = new Monocle.Controls.Scrubber(rdr); rdr.addControl(scrubber, 'standard', { container: 'scrubber' });
var stencil = new Monocle.Controls.Stencil(rdr); rdr.addControl(stencil);
});

Source: (StackOverflow)

Monocle library for ebook android blank screen is coming

I am trying to load the html tags in webview using monocore.js and monocore.css.

this is the url https://github.com/joseph/Monocle

issue is this monocle is loading, but in display blank screen is coming.

this is the code html code

     newString =  "<head> <script src=\"file:///android_asset/Monocle/dist/scripts/monocore.js\"></script>\n" +
    "<link rel=\"stylesheet\" type=\"text/css\" rel='nofollow' href=\"file:///android_asset/Monocle/dist/styles/monocore.css\" />\n" +
    "<style>\n" +
    " #reader { \n" +
            "  width: 300px;\n" +
            " height: 400px;\n" +
            " border: 1px solid #000;\n"+
             "}\n" +
    "</style>\n" +
    "</head>" +
    "<body>" +
    //<!-- The reader element, with all content to paginate inside it -->
    "<div id=\"reader\">"
           +"  <p>\n" +
           "      For a long time he lived in the toy cupboard or on the nursery floor, and no one thought very much about him.  He was naturally shy, and being only made of velveteen, some of the more expensive toys quite snubbed him.  The mechanical toys were very superior, and looked down upon every one else; they were full of modern ideas, and pretended they were real.  The model boat, who had lived through two seasons and lost most of his paint, caught the tone from them and never missed an opportunity of referring to his rigging in technical terms.  The Rabbit could not claim to be a model of anything, for he didn&#8217;t know that real rabbits existed; he thought they were all stuffed with sawdust like himself, and he understood that sawdust was quite out-of-date and should never be mentioned in modern circles.  Even Timothy, the jointed wooden lion, who was made by the disabled soldiers, and should have had broader views, put on airs and pretended he was connected with Government.  Between them all the poor little Rabbit was made to feel himself very insignificant and commonplace, and the only person who was kind to him at all was the Skin Horse.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      The Skin Horse had lived longer in the nursery than any of the others.  He was so old that his brown coat was bald in patches and showed the seams underneath, and most of the hairs in his tail had been pulled out to string bead necklaces.  He was wise, for he had seen a long succession of mechanical toys arrive to boast and swagger, and by-and-by break their mainsprings and pass away, and he knew that they were only toys, and would never turn into anything else.  For nursery magic is very strange and wonderful, and only those playthings that are old and wise and experienced like the Skin Horse understand all about it.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;What is <em>Real</em>?&#8221; asked the Rabbit one day, when they were lying side by side near the nursery fender, before Nana came to tidy the room.  &#8220;Does it mean having things that buzz inside you and a stick-out handle?&#8221;\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;Real isn&#8217;t how you are made,&#8221; said the Skin Horse.  &#8220;It&#8217;s a thing that happens to you.  When a child loves you for a long, long time, not just to play with, but <em>really</em> loves you, then you become Real.&#8221;\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;Does it hurt?&#8221; asked the Rabbit.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;Sometimes,&#8221; said the Skin Horse, for he was always truthful.  &#8220;When you are Real you don&#8217;t mind being hurt.&#8221;\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;Does it happen all at once, like being wound up,&#8221; he asked, &#8220;or bit by bit?&#8221;\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;It doesn&#8217;t happen all at once,&#8221; said the Skin Horse.  &#8220;You become.  It takes a long time.  That&#8217;s why it doesn&#8217;t happen often to people who break easily, or have sharp edges, or who have to be carefully kept.  Generally, by the time you are Real, most of your hair has been loved off, and your eyes drop out and you get loose in the joints and very shabby.  But these things don&#8217;t matter at all, because once you are Real you can&#8217;t be ugly, except to people who don&#8217;t understand.&#8221;\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;I suppose <i>you</i> are real?&#8221; said the Rabbit.  And then he wished he had not said it, for he thought the Skin Horse might be sensitive.  But the Skin Horse only smiled.\n" +
           "      </p>\n" +
           "\n" +
           "      <p>\n" +
           "      &#8220;The Boy&#8217;s Uncle made me Real,&#8221; he said.  &#8220;That was a great many years ago; but once you are Real you can&#8217;t become unreal again.  It lasts for always.&#8221;\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      The Rabbit sighed.  He thought it would be a long time before this magic called Real happened to him.  He longed to become Real, to know what it felt like; and yet the idea of growing shabby and losing his eyes and whiskers was rather sad.  He wished that he could become it without these uncomfortable things happening to him.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      There was a person called Nana who ruled the nursery.  Sometimes she took no notice of the playthings lying about, and sometimes, for no reason whatever, she went swooping about like a great wind and hustled them away in cupboards.  She called this &#8220;tidying up,&#8221; and the playthings all hated it, especially the tin ones.  The Rabbit didn&#8217;t mind it so much, for wherever he was thrown he came down soft.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      One evening, when the Boy was going to bed, he couldn&#8217;t find the china dog that always slept with him.  Nana was in a hurry, and it was too much trouble to hunt for china dogs at bedtime, so she simply looked about her, and seeing that the toy cupboard door stood open, she made a swoop.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;Here,&#8221; she said, &#8220;take your old Bunny!  He&#8217;ll do to sleep with you!&#8221;   And she dragged the Rabbit out by one ear, and put him into the Boy&#8217;s arms.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      That night, and for many nights after, the Velveteen Rabbit slept in the Boy&#8217;s bed.  At first he found it rather uncomfortable, for the Boy hugged him very tight, and sometimes he rolled over on him, and sometimes he pushed him so far under the pillow that the Rabbit could scarcely breathe.  And he missed, too, those long moonlight hours in the nursery, when all the house was silent, and his talks with the Skin Horse.  But very soon he grew to like it, for the Boy used to talk to him, and made nice tunnels for him under the bedclothes that he said were like the burrows the real rabbits lived in.  And they had splendid games together, in whispers, when Nana had gone away to her supper and left the night-light burning on the mantelpiece.  And when the Boy dropped off to sleep, the Rabbit would snuggle down close under his little warm chin and dream, with the Boy&#8217;s hands clasped close round him all night long.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      And so time went on, and the little Rabbit was very happy–so happy that he never noticed how his beautiful velveteen fur was getting shabbier and shabbier, and his tail becoming unsewn, and all the pink rubbed off his nose where the Boy had kissed him.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      Spring came, and they had long days in the garden, for wherever the Boy went the Rabbit went too.  He had rides in the wheelbarrow, and picnics on the grass, and lovely fairy huts built for him under the raspberry canes behind the flower border.  And once, when the Boy was called away suddenly to go out to tea, the Rabbit was left out on the lawn until long after dusk, and Nana had to come and look for him with the candle because the Boy couldn&#8217;t go to sleep unless he was there.  He was wet through with the dew and quite earthy from diving into the burrows the Boy had made for him in the flower bed, and Nana grumbled as she rubbed him off with a corner of her apron.\n" +
           "      </p>\n" +
           "\n" +
           "      <p class=\"center\">\n" +
           "        <img alt=\"spring\" src=\"images/spring.jpg\" /><br />\n" +
           "        <i>Spring Time</i>\n" +
           "      </p>\n" +
           "\n" +
           "      <p>\n" +
           "      &#8220;You must have your old Bunny!&#8221; she said.  &#8220;Fancy all that fuss for a toy!&#8221;\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      The Boy sat up in bed and stretched out his hands.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;Give me my Bunny!&#8221; he said.  &#8220;You mustn&#8217;t say that.  He isn&#8217;t a toy.  He&#8217;s <em>real</em>!&#8221;\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      When the little Rabbit heard that he was happy, for he knew that what the Skin Horse had said was true at last.  The nursery magic had happened to him, and he was a toy no longer.  He was Real.  The Boy himself had said it.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      That night he was almost too happy to sleep, and so much love stirred in his little sawdust heart that it almost burst.  And into his boot-button eyes, that had long ago lost their polish, there came a look of wisdom and beauty, so that even Nana noticed it next morning when she picked him up, and said, &#8220;I declare if that old Bunny hasn&#8217;t got quite a knowing expression!&#8221;\n" +
           "      </p>\n" +
           "\n" +
           "      <p class=\"center\">&asymp;</p>\n" +
           "\n" +
           "      <p>\n" +
           "      That was a wonderful Summer!\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      Near the house where they lived there was a wood, and in the long June evenings the Boy liked to go there after tea to play.  He took the Velveteen Rabbit with him, and before he wandered off to pick flowers, or play at brigands among the trees, he always made the Rabbit a little nest somewhere among the bracken, where he would be quite cosy, for he was a kind-hearted little boy and he liked Bunny to be comfortable.  One evening, while the Rabbit was lying there alone, watching the ants that ran to and fro between his velvet paws in the grass, he saw two strange beings creep out of the tall bracken near him.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      They were rabbits like himself, but quite furry and brand-new.  They must have been very well made, for their seams didn&#8217;t show at all, and they changed shape in a queer way when they moved; one minute they were long and thin and the next minute fat and bunchy, instead of always staying the same like he did.  Their feet padded softly on the ground, and they crept quite close to him, twitching their noses, while the Rabbit stared hard to see which side the clockwork stuck out, for he knew that people who jump generally have something to wind them up.  But he couldn&#8217;t see it.  They were evidently a new kind of rabbit altogether.\n" +
           "      </p>\n" +
           "\n" +
           "      <p>\n" +
           "      They stared at him, and the little Rabbit stared back.  And all the time their noses twitched.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;Why don&#8217;t you get up and play with us?&#8221; one of them asked.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;I don&#8217;t feel like it,&#8221; said the Rabbit, for he didn&#8217;t want to explain that he had no clockwork.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;Ho!&#8221; said the furry rabbit.  &#8220;It&#8217;s as easy as anything,&#8221; And he gave a big hop sideways and stood on his hind legs.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;I don&#8217;t believe you can!&#8221; he said.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;I can!&#8221; said the little Rabbit.  &#8220;I can jump higher than anything!&#8221; He meant when the Boy threw him, but of course he didn&#8217;t want to say so.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;Can you hop on your hind legs?&#8221; asked the furry rabbit.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      That was a dreadful question, for the Velveteen Rabbit had no hind legs at all!  The back of him was made all in one piece, like a pincushion.  He sat still in the bracken, and hoped that the other rabbits wouldn&#8217;t notice.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;I don&#8217;t want to!&#8221; he said again.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      But the wild rabbits have very sharp eyes.  And this one stretched out his neck and looked.\n" +
           "      </p>\n" +
           "      <p>\n" +
           "      &#8220;He hasn&#8217;t got any hind legs!&#8221; he called out.  &#8220;Fancy a rabbit without any hind legs!&#8221; And he began to laugh.\n" +
           "      </p>\n "
           +

    "</div>" +

   // <!-- Instantiate the reader when the containing element has loaded -->
    "<script>"+
            "Monocle.Reader('reader');"+
    "</script>"+
    "</body>" ;

Here i am loading that String in webview

    WebView  webview = (WebView)findViewById(R.id.webview);
    WebSettings webSettings = webview.getSettings();
    webview.getSettings().setPluginState(WebSettings.PluginState.ON);

    webview.getSettings().setJavaScriptEnabled(true);
    webview.setWebViewClient(new WebViewClient());
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setDomStorageEnabled(true);

    webSettings.setJavaScriptEnabled(true);
    webview.loadDataWithBaseURL("/notreal/", newString, "text/html", "UTF-8", null);

Please somebody help me.


Source: (StackOverflow)

TestFX - test entire application + how to execute test with monocle

I want to ask how to test entire application with testFX? I tried this:

public class HelloWorldGuiTest extends GuiTest {
private static final SettableFuture<Stage> stageFuture = SettableFuture.create();
  protected static class TestHelloWorld extends HelloWorld {
    public TestHelloWorld() {
      super();
    }

    @Override
    public void start(Stage primaryStage) throws IOException {
      super.start(primaryStage);
      stageFuture.set(primaryStage);
    }
  }

  @Before
  @Override
  public void setupStage() throws Throwable {
    assumeTrue(!UserInputDetector.instance.hasDetectedUserInput());

    FXTestUtils.launchApp(TestHelloWorld.class); // You can add start parameters here
    try {
      stage = targetWindow(stageFuture.get(25, TimeUnit.SECONDS));
      FXTestUtils.bringToFront(stage);
    } catch (Exception e) {
      throw new RuntimeException("Unable to show stage", e);
    }
  }

  @Override
  protected Parent getRootNode() {
    return stage.getScene().getRoot();
  }

  // Add your tests here

}

I replaced helloword with my application but I have some issues here. I mean I can execute test but not everything work and when I launch app by myself and try it manually its work correct.

So is there another way how to launch my app and test it?

I tried here just launch my app without extends and its not working.

FXTestUtils.launchApp(HelloWorld.class);

Next question is how I can launch application with argument? Last question is how I can execute test with Monocle? Headless test ?

Thank you


Source: (StackOverflow)

Monocle ebook reader - how to load a book data object rather than sample text

I am trying to test monocle for a brief pdf, but I can't even get the super-basic sample to work with the index, content1 and content2 files. All that shows up in the body is the word "test" that's currently in the reader div. Is there some other code that I'm supposed to insert in place of the word test?

@magicianlam got a one-page pdf to work (would you mind posting your index.html so I can see the whole thing)?

I've been at this a few hours and can't find complete get started instructions, and GitHub is getting circular as I click and read and still can't put it all together. Also, the sample book there doesn't work, even if I correct the file paths to what must be a new structure in 3.20.

For reference, I downloaded the latest version (3.20). Also, I am not able to see the controls tests (no content shows up in the frames) or the Dickens test (no content or controls show up, just the background) in IE, FF or Chrome, so maybe the version itself has an issue. Thanks for any help.


Source: (StackOverflow)

mustache is iterating an string as a list

I'm developing an application with mustache as template renderer, but I am getting some strange behaviours:

I pass this object to the template:

{
CreationDate: "2014-03-24 12:58:22"
Email: "mail@mail.es"
Id: 1
LastName: "lastname"
Name: "name"
Telephone: "123456789"
UpdateDate: "2014-03-24 12:58:22"
UserName: "webmaster"
className: "users"
uid: "DE1C1707-77A7-463D-81B6-60488D0DD17C"
}

Then I render the template, and the strange things come in this part:

...

{{#Name}}
     <button type="button" class="btn btn-info" id="resetPassword">reset</button
{{/Name}}

...

the result is that mustache draws a button for each character in the string Name. I think is treating the string like a list of objects with a number of items inside equal to the number of characters in the string value. Pretty weird

Anyone saw that before? Is there any way to avoid it?

Thank you for reading guys.

(Edit) Environment Information:

I am developing an api in php (that not interacts with this part of the app), the client aplication is html - js (coffescript) with monocle as javascript mvc and jquery. I pass the monocle user model to the mustache template that is instantiated inside a controller (coffeescript):

setUp:(model = null)->
    form = new usersForm
    form.append(if model == null then {} else model)

UPDATE::

I didn't found the solution. I tried in trymustache.com, and there the code works, but not in my project (using the exact object and the same code)


Source: (StackOverflow)

How do I load the Monocle Web eBook/ePub Reader without an iFrame?

I am using the Monocle Web eBook Reader (https://github.com/joseph/monocle & http://monocle.inventivelabs.com.au/) and am looking to add the following functionality to it:

1) Text Highlighting 2) Bookmarks 3) Notes

The main question I have is: How do you load this eBook reader without an iFrame?

The reason I want this is because I want to edit the contents of this iframe to be able to add Highlights, Notes, Bookmarks, etc.

Also "mouseup/click" events are not working on the contents of the iframe... they are working on the other elements monocle plugin is creating but not on the contents of the iframe.

Any help would be appreciated. Thank you for your time!


Source: (StackOverflow)

Javascript class instance not found

I am using MonocleMVC. I am creating a new class instance with the following code :

__Controller.Lists = new ListCtrl('article#lists')

(__ internally refers to Monocle)

The code inside ListCtrl works, but I can't access the variable __Controller.Lists. It says it is undefined.

However, __Controler.Sessions is defined in the following code :

__Controller.Sessions = new SessionCtrl('section#splash')

UPDATE

It seems this code prevents the class from being defined :

class ListCtrl extends Monocle.Controller

# THIS CONSTRUCTOR
  constructor: ->
    super
    __Model.List.bind "create", @bindCreate
    __Model.List.bind "change", @bindChange
    __Model.List.bind "error", @bindError
    __Model.List.bind "destroy", @bindDestroy
    @bindChange()

UPDATE 2

Turnet out @bindChange() was the cause. Any idea why?


Source: (StackOverflow)