Loading...

resourcespace@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: Idea - use google docs viewer for doc, pdf etc display Vasik Greif Wed Feb 22 01:01:20 2012

ups, I missed

$resource=get_resource_data($ref);

in the code...
Vasik

On 22 ún, 09:59, Vasik Greif <[EMAIL PROTECTED]> wrote:
> Now this is cool, thanks David, exactly what was needed to be done!!!
>
> Just to maybe save you some time, here's the code that should work for
> getting the array into book plugin (there might be better way, I took
> this from resource_functions.php):
>
> <?php
> function HookBookAllpreviewimage ()
> {
> $ref=getval("ref","");
> if ($resource['file_extension'] == "pdf") {
>
> // get pages files
> $page = 1;
> $filearray=array();
>     $misscount = 0;
>     // just to be safe, we'll try at least 4 pages ahead to make sure
> none got skipped
>     while($misscount < 4){
>         $thepath =
> get_resource_path(270,true,"scr",false,'jpg',-1,$page,"","","");
>         if (file_exists($thepath)){
>             array_push($filearray,$thepath);
>             $page++;
>         } else {
>             $misscount++;
>             $page++;
>         }
>     }
> $pagesno=count($filearray);
> ?>
>
> <!-- code from SimpleBookDemo.js goes here -->
>
> <?php
> return true;}}
>
> ?>
>
> For getting the array into JS array, one could do something like:
>
> var myarray = new Array(<?php echo "'".implode("','",
> $filearray)."'"; ?> );
>
> or use json_encode function..
>
> Thanks
> Vasik
>
> On 22 ún, 05:15, David Dwiggins <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
> > Hi, Vasik and Matt
>
> > I just spent a couple of hours working with the IA simple example, and was
> > able to get it to pull the pre-existing images from the RS database. What I
> > did is a really rough proof of concept, but it shows that it can be done.
>
> > I didn't do a screencast, but it looks pretty much like what Vasik did only
> > without the RS interface around it yet.
>
> > The trick is to generate the activating javascript and html from php code,
> > so that you can insert the necessary data from the ResourceSpace database.
> > I loaded the list of file URLs for the PDF into a javascript array, and
> > then modified the URL function in the example script to get it to read from
> > the array rather than making up a plain numeric URL.  This could probably
> > also be done on the fly with ajax, although I'm not sure there's much
> > benefit to doing it that way.
>
> > This would take some work to get it to production quality, but it's
> > definitely do-able. Considerably more development would be required to
> > support the advanced features of the reader like arbitrary scaling, search
> > within the book, etc. But even with the basic "simple" example it's an
> > improvement over the current built-in pager.
>
> > I think it could easily be developed as a plugin or added to the base code.
> > One issue might be figuring out how the open source license is worded and
> > whether distributing it within the RS base is a problem. I doubt it, since
> > GPL and BSD licenses are both pretty permissive. But probably needs to be
> > looked at before it can be put in the base. Putting it a plugin might be
> > less of an issue, since it would be self contained.
>
> > Don't have any more time to play with this tonight, but figured I'd give a
> > progress report.
>
> > -David
>
> > On Tue, Feb 21, 2012 at 6:07 PM, Vasik Greif <[EMAIL PROTECTED]> wrote:
> > > > @Vaisck
> > > > Impressive and quick. Questions:
>
> > > >    1. Is this in the basecode or as a plugin?
> > > >    2. How does RS build the page list now say of a PDF it rasterizes vs
> > > the
> > > >    IA ereader?
>
> > > Let me answer both questions by describing what I did:
>
> > > When PDF gets uploaded, the preview images are created in
> > > preview_preprocessing.php, with random names. I basically duplicated
> > > this code and modified it to store the images into specified folder
> > > inside the resource folder (ie. resourcefolder/book/) and with
> > > sequentional names (001.jpg, 002jpg etc).
> > > Than I created a plugin, which replaces the previewimage hook in
> > > preview.php with the IA reader. I basically took the BookReaderDemo,
> > > copy/pasted the BookReaderJSSimple.js code and just specified the path
> > > to the resourcefolder/book and number of pages. Then the reader
> > > automatically takes the images and builds book.
>
> > > So, while this works, this is not a good solution, as the preview
> > > images are created twice now. Ideally, we should use the previews that
> > > are already done by RS, and just tell the reader to build a book -
> > > that way we won't screw up anything inside RS, there would be no need
> > > to modify the core, and the reader could be displayed just by simple
> > > plugin.
>
> > > The function to get the images in JS is (taken from the
> > > BookReaderJSSimple.js):
>
> > > // We load the images from archive.org -- you can modify this function
> > > to retrieve images
> > > // using a different URL structure
> > > br.getPageURI = function(index, reduce, rotate) {
> > >    // reduce and rotate are ignored in this simple implementation,
> > > but we
> > >    // could e.g. look at reduce and load images from a different
> > > directory
> > >    // or pass the information to an image server
> > >    var leafStr = '000';
> > >    var imgStr = (index+1).toString();
> > >    var re = new RegExp("0{"+imgStr.length+"}$");
> > >    var url = 'http://www.archive.org/download/BookReader/img/
> > > page'+leafStr.replace(re, imgStr) + '.jpg';
> > >    return url;
> > > }
>
> > > For sure there's a function in RS to get the array of images previews,
> > > that belong to the pdf (I can check that tomorrow, or Dan can tell
> > > us), so what we need is to modify the JS code to accept the array. I'm
> > > sorry, I don't know anything about JS. Anyone?
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "ResourceSpace" group.
> > > To post to this group, send email to [EMAIL PROTECTED]
> > > To unsubscribe from this group, send email to
> > > [EMAIL PROTECTED]
> > > For more options, visit this group at
> > >http://groups.google.com/group/resourcespace?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"ResourceSpace" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/resourcespace?hl=en.