diff options
author | Jörg Frings-Fürst <jff@merkur> | 2014-07-06 15:20:38 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <jff@merkur> | 2014-07-06 15:20:38 +0200 |
commit | 126bb8cb6b93240bb4d3a2b816b74c286c3d422b (patch) | |
tree | e66e1dfe77d53a52539489765c88d23e4423ae27 /templates |
Imported Upstream version 1.7.0upstream/1.7.0
Diffstat (limited to 'templates')
-rw-r--r-- | templates/GCExportTemplate.pm | 264 | ||||
-rw-r--r-- | templates/GCImportTemplate.pm | 212 | ||||
-rw-r--r-- | templates/GCSiteTemplate.pm | 271 |
3 files changed, 747 insertions, 0 deletions
diff --git a/templates/GCExportTemplate.pm b/templates/GCExportTemplate.pm new file mode 100644 index 0000000..d1ca4c4 --- /dev/null +++ b/templates/GCExportTemplate.pm @@ -0,0 +1,264 @@ +# Replace Template with your exporter name. +# The package name must exactly match the file name (.pm) +package GCExport::GCExportTemplate; + +################################################### +# +# Copyright 2005-2007 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +use GCExport::GCExportBase; + +{ + # Replace Template with your exporter name + # It must be the same name as the one used for file and main package name + package GCExport::GCExporterTemplate; + + use base qw(GCExport::GCExportBaseClass); + + # Add your needed use clauses here + + # new + # Constructor + # Returns reference to current object. + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + + # Do your initialization stuff here + + bless ($self, $class); + return $self; + } + + # getName + # Used to create Export menu. + # If you need a string that depends on language, do NOT define + # this method and provide a member called Name in languages files + # Returns a string containing the name. + sub getName + { + my $self = shift; + + # Should return the exporter name as it will be displayed in Export menu. + + return "Template"; + } + + # getOptions + # Used to create export dialog window. + # Returns an array with needed options. + sub getOptions + { + my $self = shift; + + # Should return an array of associative arrays. + # Here is an example. + + return [ + { + name => 'withJs', + type => 'checkBox', + label => 'ExportHTMLWithJS', + default => '1' + }, + + { + name => 'title', + type => 'shortText', + label => 'ExportHTMLTitle', + default => 'Movies list' + }, + + ] + + # For each entry, you have to specify: + # + # - name: A unique name that will be used to retrieve the option value + # - type: One out of checkBox, shortText, longText, number, list, fileSelection, colorSelection + # - label: a member of lang files (lib/gcstar/GCLang/*.pm) that will be used to display an informative label + # - default: Default value (for the first time exporter is used in a session). + # + # There are other values that are only valid for some types. + # + # - min: Minimum value allowed (for number only). + # - max: Maximum value (for number only). + # - height: Height of the widget displayed in pixels (for longText only). + # - valuesList: A comma separated list of values to be used (for list only). + # - buttonLabel: Label for a button that will be displayed next to the option + # (only for shortText, longText, number, list) + # - buttonCallback: Callback to be called when clicking on the button. It will + # get button as first parameter while the second one will + # a reference to an array containing dialog and option handles. + # (only used if buttonLabel is specified). + + # In all processing functions below, values entered by user are accessible through: + # + # $self->{options}->{name} + # + # Where name should be replaced with specified name above. + + + } + + # In there processing functions, you can use options fields specified through getOptions + # But there is also some predifined values: + # + # - $self->{options}->{file} File name used to export data. + # - $self->{options}->{collection} File name of the one containing movies list. + # - $self->{options}->{collectionDirectory} Directory where movies list file is. + # - $self->{options}->{movies} A reference to the array containing the information. + # - $self->{options}->{lang} A reference to the hash containing current language translations. + # - $self->{options}->{fields} A reference to an array containing fields user choosed + # (wantsFieldsSelection must return a true value for this to be used). + + # wantsFieldsSelection + # This function lets a plugin decide if it wants the user to specify fields to be used + # Returns a true value when fields selection is needed. + sub wantsFieldsSelection + { + return 0; + } + + # needsUTF8 + # With this method, a plugin may ask the output file to be in UTF-8 mode + # Returns a true value when UTF-8 is needed. + sub needsUTF8 + { + return 0; + } + + # preProcess + # Use this function if you need to do special stuff before movies list processing. + # Returns nothing + sub preProcess + { + my $self = shift; + + # Your code here + } + + # getHeader + # Should create the beginning of the exported file. + # $number is the total movies number. + # Returns a string containing what have to be included on the top of the file. + sub getHeader + { + my ($self, $number) = @_; + my $result; + + # Your code here + # Append data to $result; + + return $result; + } + + # getItem + # Called for each movie. + # $movie is an associative array containing the movie information. They are: + # + # - $movie->{title} + # - $movie->{date} + # - $movie->{year} + # - $movie->{time} + # - $movie->{director} + # - $movie->{country} + # - $movie->{age} + # - $movie->{type} + # - $movie->{image} + # - $movie->{original} + # - $movie->{actors} + # - $movie->{comment} + # - $movie->{synopsis} + # - $movie->{seen} + # - $movie->{number} + # - $movie->{rating} + # - $movie->{format} + # - $movie->{url} + # - $movie->{place} + # - $movie->{video} + # - $movie->{audio} + # - $movie->{audioEncoding} + # - $movie->{subt} + # - $movie->{borrower} + # - $movie->{lendDate} + # - $movie->{history} + # + # $number is the movie index + # Returns the item string. + sub getItem + { + my ($self, $movie, $number) = @_; + my $result; + + # Your code here + # Append data to $result; + + return $result; + } + + # getFooter + # Should create the end of the exported file. + # Returns a string containing what have to be included on the end of the file. + sub getFooter + { + my $self = shift; + my $result; + + # Your code here + # Append data to $result; + + return $result; + } + + # postProcess + # Called after all processing. Use it if you need to perform extra stuff on the header. + # $header is a reference to the header string. + # $body is a reference to the content string. + sub postProcess + { + my ($self, $header, $body) = @_; + + # Your code here + # As header is a reference, it can be modified on place with $$header + # The same for $$body + } + + # getEndInfo + # Used to display some information to user when export is ended. + # To localize your message, use $self->{options}->{lang}. + # Returns a string that will be displayed in a message box. + sub getEndInfo + { + my $self = shift; + my $message; + + # Your code here + # Don't do put anything in message if you don't want information to be displayed. + + return $message; + } +} + +1;
\ No newline at end of file diff --git a/templates/GCImportTemplate.pm b/templates/GCImportTemplate.pm new file mode 100644 index 0000000..b0e5e76 --- /dev/null +++ b/templates/GCImportTemplate.pm @@ -0,0 +1,212 @@ +# Replace Template with your importer name. +# The package name must exactly match the file name (.pm) +package GCImport::GCImportTemplate; + +################################################### +# +# Copyright 2005-2007 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; + +use GCImport::GCImportBase; + +{ + # Replace Template with your importer name + # It must be the same name as the one used for file and main package name + package GCImport::GCImporterTemplate; + + use base qw(GCImport::GCImportBaseClass); + + # Add your needed use clauses here + + # new + # Constructor + # Returns reference to current object. + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + + # Do your initialization stuff here + + bless ($self, $class); + return $self; + } + + # wantsFieldsSelection + # This function lets a plugin decide if it wants the user to specify fields to be used + # Returns a true value when fields selection is needed. + sub wantsFieldsSelection + { + return 0; + } + + # wantsFileSelection + # Some plugins doens't need a file (they can get their information + # from a database as an example. This function specify if a file + # is needed or not. + # Returns true if a file is needed. + sub wantsFileSelection + { + return 1; + } + + + # getName + # Used to create Import menu. + # If you need a string that depends on language, do NOT define + # this method and provide a member called Name in languages files + # Returns a string containing the name. + sub getName + { + my $self = shift; + + # Should return the importer name as it will be displayed in Import menu. + + return "Template"; + } + + # getFilePatterns + # Used to add filters in file selection dialog box. + # A *.* filter is always added also. + # Returns the file as a list of array references. + sub getFilePatterns + { + return (['Description 1', '*.ext1'], ['Description 2', '*.ext2']); + } + + # getOptions + # Used to create import dialog window. + # Returns an array with needed options. + sub getOptions + { + my $self = shift; + + # Should return an array of associative arrays. + # Here is an example. + + return [ + { + name => 'withJs', + type => 'checkBox', + label => 'ImportHTMLWithJS', + default => '1' + }, + + { + name => 'title', + type => 'shortText', + label => 'ImportHTMLTitle', + default => 'Movies list' + }, + + ] + + # For each entry, you have to specify: + # + # - name: A unique name that will be used to retrieve the option value + # - type: One out of checkBox, shortText, longText, number, list, fileSelection, colorSelection + # - label: a member of lang files (lib/gcstar/GCLang/*.pm) that will be used to display an informative label + # - default: Default value (for the first time exporter is used in a session). + # + # There are other values that are only valid for some types. + # + # - min: Minimum value allowed (for number only). + # - max: Maximum value (for number only). + # - height: Height of the widget displayed in pixels (for longText only). + # - valuesList: A comma separated list of values to be used (for list only). + + # In all processing functions below, values entered by user are accessible through: + # + # $self->{options}->{name} + # + # Where name should be replaced with specified name above. + + + } + + # In there processing functions, you can use options fields specified through getOptions + # But there is also some predifined values: + # + # - $self->{options}->{file} File name used to export data. + # - $self->{options}->{movies} A reference to the array containing the information. + # - $self->{options}->{lang} A reference to the hash containing current language translations. + + # getMoviesArray + # Called to generate the movies array. + # Each item of this array have to be an associative array with these fields: + # + # - $movie->{title} + # - $movie->{date} + # - $movie->{time} + # - $movie->{director} + # - $movie->{country} + # - $movie->{age} + # - $movie->{type} + # - $movie->{image} + # - $movie->{original} + # - $movie->{actors} + # - $movie->{comment} + # - $movie->{synopsis} + # - $movie->{seen} + # - $movie->{number} + # - $movie->{rating} + # - $movie->{format} + # - $movie->{url} + # - $movie->{place} + # - $movie->{video} + # - $movie->{audio} + # - $movie->{subt} + # - $movie->{borrower} + # - $movie->{lendDate} + # - $movie->{history} + # + # Returns the movies array. + sub getMoviesArray + { + my ($self, $file) = @_; + my @result; + + # Your code here + # Add movies to results; + + return \@result; + } + + + # getEndInfo + # Used to display some information to user when export is ended. + # To localize your message, use $self->{options}->{lang}. + # Returns a string that will be displayed in a message box. + sub getEndInfo + { + my $self = shift; + my $message; + + # Your code here + # Don't do put anything in message if you don't want information to be displayed. + + return $message; + } +} + +1;
\ No newline at end of file diff --git a/templates/GCSiteTemplate.pm b/templates/GCSiteTemplate.pm new file mode 100644 index 0000000..4bc6038 --- /dev/null +++ b/templates/GCSiteTemplate.pm @@ -0,0 +1,271 @@ +# +# More information here: http://wiki.gcstar.org/en/websites_plugins +# +# GCcollection should be replaced with the kind of collection your +# plugin deals with. e.g. GCfilms, GCgames, GCbooks,... + +# Replace SiteTemplate with your plugin name. +# The package name must exactly match the file name (.pm) +package GCPlugins::GCcollection::GCSiteTemplate; + +################################################### +# +# Copyright 2005-2007 Tian +# +# This file is part of GCstar. +# +# GCstar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# GCstar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCstar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +# +################################################### + +use strict; +use utf8; + +use GCPlugins::GCcollection::GCcollectionCommon; + +{ + # Replace SiteTemplate with your exporter name + # It must be the same name as the one used for file and main package name + package GCPlugins::GCcollection::GCPluginSiteTemplate; + + use base 'GCPlugins::GCcollection::GCcollectionPluginsBase'; + + # getSearchUrl + # Used to get the URL that to be used to perform searches. + # $word is the query + # Returns the full URL. + sub getSearchUrl + { + my ($self, $word) = @_; + my $url; + + # Your code here + + return $url; + } + + # getItemUrl + # Used to get the full URL of an item page. + # Useful when url on results pages are relative. + # $url is the URL as found with a search. + # Returns the absolute URL. + sub getItemUrl + { + my ($self, $url) = @_; + my $absUrl; + + # Your code here + + return $absUrl; + } + + # getCharset + # Used to convert charset in web pages. + # Returns the charset as specified in pages. + sub getCharset + { + my $self = shift; + + return "ISO-8859-1"; + } + + # getName + # Used to display plugin name in GUI. + # Returns the plugin name. + sub getName + { + return "SiteTemplate"; + } + + # getAuthor + # Used to display the plugin author in GUI. + # Returns the plugin author name. + sub getAuthor + { + return 'Tian'; + } + + # getLang + # Used to fill in plugin list with user language plugins + # Return the language used for this site (2 letters code). + sub getLang + { + return 'EN'; + } + # getExtra + # Used if the plugin wants an extra column to be displayed in search results + # Return the column title or empty string to hide the column. + sub getExtra + { + return 'Extra'; + } + + # getNumberPasses + # Used to set the number of search "passes" the plugin requires. This defaults to + # a single pass, but for some sites 2 or more searches are required. See the GCTvdb + # plugin for an example of such a site + sub getNumberPasses + { + return 1; + } + + # changeUrl + # Can be used to change URL if item URL and the one used to + # extract information are different. + # Return the modified URL. + sub changeUrl + { + my ($self, $url) = @_; + + return $url; + } + + # In processing functions below, self->{parsingList} can be used. + # If true, we are processing a search results page + # If false, we are processing a item information page. + + # $self->{inside}->{tagname} (with correct value for tagname) can be used to test + # if we are in the corresponding tag. + + # You have a counter $self->{itemIdx} that have to be used when processing search results. + # It is your responsability to increment it! + + # When processing search results, you have to fill the available fields for results + # + # $self->{itemsList}[$self->{movieIdx}]->{field_name} + # + # When processing a movie page, you need to fill the fields (if available) + # in $self->{curInfo}. + # + # $self->{curInfo}->{field_name} + + # start + # Called each time a new HTML tag begins. + # $tagname is the tag name. + # $attr is reference to an associative array of tag attributes. + # $attrseq is an array reference containing all the attributes name. + # $origtext is the tag text as found in source file + # Returns nothing + sub start + { + my ($self, $tagname, $attr, $attrseq, $origtext) = @_; + $self->{inside}->{$tagname}++; + + if ($self->{parsingList}) + { + # Your code for processing search results here + } + else + { + # Your code for processing movie information here + } + } + + # end + # Called each time a HTML tag ends. + # $tagname is the tag name. + sub end + { + my ($self, $tagname) = @_; + $self->{inside}->{$tagname}--; + + if ($self->{parsingList}) + { + # Your code for processing search results here + } + else + { + # Your code for processing movie information here + } + } + + # text + # Called each time some plain text (between tags) is processed. + # $origtext is the read text. + sub text + { + my ($self, $origtext) = @_; + + if ($self->{parsingList}) + { + # Your code for processing search results here + } + else + { + # Your code for processing movie information here + } + } + + # new + # Constructor. + # Returns object reference. + sub new + { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(); + + # This member should be initialized as a reference + # to a hash. Each keys is a field that could be + # in results with value 1 or 0 if it is returned + # or not. For the list of keys, check the model file + # (.gcm) and search for tags <field> in + # /collection/options/fields/results + $self->{hasField} = { + key1 => 1, + key2 => 0, + }; + + # Do your init stuff here + + bless ($self, $class); + return $self; + } + + # getFields + # Called on each pass, by plugins with getNumberPasses > 1 + # to get the columns return by the plugin during that pass + sub getReturnedFields + { + my $self = shift; + + # This member should be initialized as a reference + # to a hash. Each keys is a field that could be + # in results with value 1 or 0 if it is returned + # or not. For the list of keys, check the model file + # (.gcm) and search for tags <field> in + # /collection/options/fields/results + $self->{hasField} = { + key1 => 1, + key2 => 0, + }; + } + + # preProcess + # Called before each page is processed. You can use it to do some substitutions. + # $html is the page content. + # Returns modified version of page content. + sub preProcess + { + my ($self, $html) = @_; + + # Your code to modify $html here. + + return $html; + } + +} + +1; |