Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bywatersolutions/koha-plugin-cove…
Browse files Browse the repository at this point in the history
…rflow
  • Loading branch information
Kyle M Hall committed May 31, 2018
2 parents 06a8109 + 4db3dc6 commit bcd8c59
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 14 deletions.
4 changes: 4 additions & 0 deletions Koha/Plugin/Com/ByWaterSolutions/CoverFlow.pm
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ sub report {
showtitle => $self->retrieve_data('showtitle'),
size_limit => $self->retrieve_data('size_limit'),
title_limit => $self->retrieve_data('title_limit'),
use_coce => $self->retrieve_data('use_coce'),
);

print $cgi->header(
Expand Down Expand Up @@ -102,6 +103,7 @@ sub configure {
custom_image => $self->retrieve_data('custom_image'),
size_limit => $self->retrieve_data('size_limit'),
title_limit => $self->retrieve_data('title_limit'),
use_coce => $self->retrieve_data('use_coce'),
);


Expand All @@ -116,6 +118,7 @@ sub configure {
}
else {
my $coverlinks = $cgi->param('coverlinks') ? 1:0;
my $use_coce = $cgi->param('use_coce') ? 1:0;
my $showtitle = $cgi->param('showtitle') ? 1:0;
my $custom_image = $cgi->param('custom_image');
$self->store_data(
Expand All @@ -127,6 +130,7 @@ sub configure {
size_limit => $cgi->param('size_limit'),
title_limit => $cgi->param('title_limit'),
last_configured_by => C4::Context->userenv->{'number'},
use_coce => $use_coce,
}
);

Expand Down
28 changes: 20 additions & 8 deletions Koha/Plugin/Com/ByWaterSolutions/CoverFlow/configure.tt
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,28 @@ $(document).ready(function() {
<br/>
</fieldset>

<label for="custom_image">Custom image to use if none is found (enter a full URL):</label>
<input type="text" id="custom_image" name="custom_image" value="[% custom_image %]" />
<fieldset id="image options">
<legend>Image options</legend>

<br/>
<label for="size_limit">Limit image size (height in pixels)</label>
<input type="number" id="size_limit" name="size_limit" value="[% size_limit %]" />
<label for="custom_image">Custom image to use if none is found (enter a full URL):</label>
<input type="text" id="custom_image" name="custom_image" value="[% custom_image %]" />

<br/>
<label for="title_limit">Limit title length (width in pixels)</label>
<input type="number" id="title_limit" name="title_limit" value="[% title_limit %]" />
<br/>
<label for="use_coce">*EXPERIMENTAL* Use Coce for cover images.</label>
<input type="checkbox" id="use_coce" name="use_coce" [% IF (use_coce) %]checked="checked"[% END %] value="1"></input>
</br>
<p>Note you must define the url for the Coce service and select service providers in the system preferences if you choose this, you do not need to enable coce images for the catalog</p>

</br>
<label for="size_limit">Limit image size (height in pixels)</label>
<input type="number" id="size_limit" name="size_limit" value="[% size_limit %]" />

<br/>
<label for="title_limit">Limit title length (width in pixels)</label>
<input type="number" id="title_limit" name="title_limit" value="[% title_limit %]" />
</fieldset>

</br>

[% IF error %]<div class="warn alert error">Error: [% error %]</div>[% END %]

Expand Down
14 changes: 13 additions & 1 deletion Koha/Plugin/Com/ByWaterSolutions/CoverFlow/report.tt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="koha-coverflow">
[% USE Koha %]
<div class="koha-coverflow" [% IF (use_coce) %]style="min-height: 200px"[% END %]>
<ul>
[% FOREACH d IN data %]
[% IF d.isbn || d.localcover %]
Expand All @@ -7,6 +8,8 @@
<a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% d.biblionumber %]">
[% IF d.localcover %]
<img [% IF size_limit %]style="max-height:[% size_limit %]px;"[% END %] src="/cgi-bin/koha/opac-image.pl?biblionumber=[% d.biblionumber %]" />
[% ELSIF (use_coce) %]
<div style="block" title="[% d.biblionumber %]" class="[% d.isbn %]" id="coce-thumbnail-preview"></div>
[% ELSE %]
<img [% IF size_limit %]style="max-height:[% size_limit %]px;"[% END %] src="https://images-na.ssl-images-amazon.com/images/P/[% d.isbn %].01.LZZZZZZZ.jpg" />
[% END %]
Expand All @@ -18,6 +21,8 @@
[% ELSE %]
[% IF d.localcover %]
<img [% IF size_limit %]style="max-height:[% size_limit %]px;"[% END %] src="/cgi-bin/koha/opac-image.pl?biblionumber=[% d.biblionumber %]" />
[% ELSIF (use_coce) %]
<div style="block" title="[% d.biblionumber %]" class="[% d.isbn %]" id="coce-thumbnail-preview"></div>
[% ELSE %]
<img [% IF size_limit %]style="max-height:[% size_limit %]px;"[% END %] src="https://images-na.ssl-images-amazon.com/images/P/[% d.isbn %].01.LZZZZZZZ.jpg" />
[% END %]
Expand All @@ -28,4 +33,11 @@
[% END %]
[% END %]
</ul>
[% IF (use_coce) %]
<script type="text/javascript" src="/opac-tmpl/bootstrap/js/coce.js"></script>
<script type="text/javascript">
KOHA.coce.getURL('[% Koha.Preference('CoceHost') %]', '[% Koha.Preference('CoceProviders') %]',[% Koha.Preference('OPACURLOpenInNewWindow') %]);
</script>
[% END %]

</div>
56 changes: 54 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,32 @@ Once set up is complete you will need to alter your UseKohaPlugins system prefer

Once the plugin is installed, the steps to get your coverflow to show up are as follows:

First, you need to create one or more public reports for your coverflow widget or widgets to be based on. This is how the plugin knows what the content of your widget should contain. Each report needs only three columns; title, biblionumber, and isbn. It is important that you have a good and valid isbn, as that is the datum used to actually fetch the cover. In the iteration of the plugin, we are using Amazon cover images, but I believe in the end I will make the cover image fetcher configurable so we can use any data source for cover image fetching.
First, you need to create one or more public reports for your coverflow widget or widgets to be based on. This is how the plugin knows what the content of your widget should contain. Each report needs only three columns; title, biblionumber, and isbn. It is important that you have a good and valid isbn, as that is the datum used to actually fetch the cover. Example finding items added in the last 30 days:
```
SELECT b.biblionumber, SUBSTRING_INDEX(m.isbn, ' ', 1) AS isbn, b.title
FROM items i
LEFT JOIN biblioitems m USING (biblioitemnumber)
LEFT JOIN biblio b ON (i.biblionumber=b.biblionumber)
WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= i.dateaccessioned AND m.isbn IS NOT NULL AND m.isbn != ''
HAVING isbn != ""
GROUP BY biblionumber
ORDER BY rand()
LIMIT 30
```

Note: You can add an additional column 'localcover' - this should be blank if the biblio doesn't have a localcover and can contain any other data if it does. If this column is populated a local cover will be used.
In the iteration of the plugin, we are using Amazon cover images, but I believe in the end I will make the cover image fetcher configurable so we can use any data source for cover image fetching. **Coce has been added as experimental cover source feel free to test using URL https://coce.bywatersolutions.com**

Note: You can add an additional column 'localcover' - this should be blank if the biblio doesn't have a localcover and can contain any other data if it does. If this column is populated a local cover will be used. Example below:
```
SELECT DISTINCT biblio.title, biblio.biblionumber, SUBSTRING_INDEX(biblioitems.isbn, ' ', 1) AS isbn, c.imagenumber AS localcover
FROM items
LEFT JOIN biblioitems USING (biblioitemnumber)
LEFT JOIN biblio ON (items.biblionumber=biblio.biblionumber)
LEFT JOIN biblioimages c ON (items.biblionumber=c.biblionumber)
WHERE biblioitems.isbn IS NOT NULL AND biblioitems.isbn !=''
ORDER BY RAND()
LIMIT 15
```

Second, we need to configure the plugin.
The first option is whether to use coverimages as the links to the biblios, and whether or not to display titles under images if so.
Expand Down Expand Up @@ -76,6 +99,35 @@ The final step is to put your selector element somewhere in your public catalog.
```

Once that is in place, you need only refresh your OPAC page, and there you have it, your very own catalog coverflow widget! Not only do these coverflows look great on a computer screen, but they look great on mobile platforms as well, and are even touch responsive!
# Report with parameters
It is now possible to use reports that take input. For example,in a multibranchsystem you can setup a single report as below:
```
SELECT b.biblionumber, SUBSTRING_INDEX(m.isbn, ' ', 1) AS isbn, b.title
FROM items i
LEFT JOIN biblioitems m USING (biblioitemnumber)
LEFT JOIN biblio b ON (i.biblionumber=b.biblionumber)
WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= i.dateaccessioned AND m.isbn IS NOT NULL AND m.isbn != ''
AND items.homebranch = <<Branch|branches>>
HAVING isbn != ""
GROUP BY biblionumber
ORDER BY rand()
LIMIT 30
```
Then in the plugin configuration you can use thismultiple times:
```
- id: 42
selector: #coverflow1
params:
- BRANCHA
options:
style: coverflow
- id: 42
selector: #coverflow2
params:
- BRANCHB
options:
style: coverflow
```

# Build and release

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koha-coverflow-plugin",
"version": "2.4.5",
"previous_version": "2.4.4",
"version": "2.4.7",
"previous_version": "2.4.6",
"description": "Koha CoverFlow Plugin",
"main": "index.js",
"dependencies": {
Expand Down

0 comments on commit bcd8c59

Please sign in to comment.