[Catalyst] Using CatalystX::I18N::Maketext outside of Catalyst

2022-01-21 Thread Chris Welch
Hi - I hope it's okay to post this here, I know it's not about Catalyst
'core'.

I'm using CatalystX::I18N::* in order to be able to internationalise my
site.  I have that working nicely, and my site text is coming from
$c->maketext().

However, I've been trying to access these codes from my database model (in
order to generate, e.g., success or failure messages when checking input
before creating / updating) and am struggling.

According to the CatalystX::I18N docs, CatalystX::I18N::Maketext is a
'Helpful wrapper around Locale::Maketext. Can also be used outside of
Catalyst'.

I have MyApp::Maketext setup as directed:

package MyApp::Maketext;

use strict;
use warnings;
use parent qw(CatalystX::I18N::Maketext);

1;

I have a little test script running, the setup for which is this:

#!/usr/bin/perl

use strict;
use warnings;
use FindBin qw( $Bin );
use lib "$Bin/../lib";
use TopTable::Maketext;
use Path::Class::Dir;

my $dir = Path::Class::Dir->new( "$Bin/..", "root", "locale" );
TopTable::Maketext->load_lexicon(
  locales => ["en_GB"], # Required
  directories => [$dir], # Required
  gettext_style => 0, # Optional, Default 1
);

I am then trying two different ways to get a handle to the maketext()
method:

my $lang = TopTable::Maketext->get_handle;
printf "%s\n", $lang->maketext( "menu.title.news" );

Gives the following result:
Can't call method "maketext" on an undefined value at bin\maketext-demo.pl
line 23.

If I swap ->get_handle to ->new:
my $lang = TopTable::Maketext->new;
printf "%s\n", $lang->maketext( "menu.title.news" );

I get the following:
maketext doesn't know how to say:
menu.title.news
as needed at bin\maketext-demo.pl line 23.

I'm at a bit of a loss as to what to try next!  Thank you so much in
advance for any pointers anyone can give.


Chris
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] $c->uri_for and $c->uri_for_action ignoring https

2021-10-02 Thread Chris Welch
Apologies, I have sorted this - I must have forgotten that I had set
the using_frontend_proxy option and then set the X-Forwarded-Port header on
nginx before.

On Sat, 2 Oct 2021 at 14:35, Chris Welch  wrote:

> Hi everyone
>
> In my infinite(!) wisdom, I decided to do a complete server rebuild before
> people will start using my website again next month.  This previously was
> working correctly, however now even though the page is being served over
> https, all the links (which use $c->uri_for and $c->uri_for_action) are
> returning http versions, which is causing the style sheets to fail to load
> for one thing, but also form submissions are going over http.
>
> Some things that may be pertinent:
>
>
>- Using nginx / Starman (same as before).
>- This is using a letsencrypt certificate, which it was before, but
>when I set it up before there wasn't a certbot to automate it, so it was
>done manually.
>- Website in case it's useful: https://www.mkttl.co.uk/
>- Catalyst version is now the latest - previously I *think* it
>was 5.90118, but unfortunately can't be sure.
>
> Thank you in advance for any suggestions!
>
>
> Chris
>
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] $c->uri_for and $c->uri_for_action ignoring https

2021-10-02 Thread Chris Welch
Hi everyone

In my infinite(!) wisdom, I decided to do a complete server rebuild before
people will start using my website again next month.  This previously was
working correctly, however now even though the page is being served over
https, all the links (which use $c->uri_for and $c->uri_for_action) are
returning http versions, which is causing the style sheets to fail to load
for one thing, but also form submissions are going over http.

Some things that may be pertinent:


   - Using nginx / Starman (same as before).
   - This is using a letsencrypt certificate, which it was before, but when
   I set it up before there wasn't a certbot to automate it, so it was done
   manually.
   - Website in case it's useful: https://www.mkttl.co.uk/
   - Catalyst version is now the latest - previously I *think* it
   was 5.90118, but unfortunately can't be sure.

Thank you in advance for any suggestions!


Chris
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Multipart/form-data file uploads missing

2016-11-14 Thread Chris Welch
I think the file upload is in $c->request->upload - I have a file called
"image", which I access with $c->request->upload("image"), does that help?
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] An MVC logic separation conundrum

2016-03-14 Thread Chris Welch
Thank you all very much for your help, it's given me some real food for
thought.
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] An MVC logic separation conundrum

2016-03-10 Thread Chris Welch
​Thank you so much for this, that makes a lot more sense now.​


>
> I’m not sure what you’re asking. Do you mean you want to get rid of the
> `sub { ... }` noise and just pass in “a method call”? If so, no, there
> is no way of doing that in Perl.
>

​My original question was not about passing the method call in per se, but
the return value from that method call, but I see it would be a lot cleaner
the way you have suggested.

​Thanks again.​
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] An MVC logic separation conundrum

2016-03-10 Thread Chris Welch
On 10 March 2016 at 12:42, Aristotle Pagaltzis  wrote:

> * Chris Welch  [2016-03-09 20:10]:
> > All of this brings up a quandary: there are only two ways around this
> > that I can see:
>
> There’s plenty more. E.g. you could have generate_ical_data expect one
> or several callbacks to generate those values for it, something like
>
> ​​
> $match->generate_ical_data(
> get_uri => sub { $c->uri_for_action( ... ) },
> get_description => sub { $c->maketext( ... ) },
> # ...
> );
> ​
>

​Oh I very much like that - I *knew* ​I had to be missing a better way of
doing it, I bow to your superior ideas, thank you very much.

Thinking about it: any way you would pass in an anonymous sub rather than
the return value from the actual methods - i.e.:

​
$match->generate_ical_data(
get_uri => $c->uri_for_action( ... ) ,
get_description => $c->maketext( ... ) ,
# ...
);
​


​Thanks again.​
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] An MVC logic separation conundrum

2016-03-10 Thread Chris Welch
Thank you for the validation - I thought that was the case.

On 9 March 2016 at 22:11, Darren Duncan  wrote:

> The best option is to keep the concerns separated.  Models should always
> take their inputs via explicit arguments for a Model-specific API, and they
> should not have any knowledge of or direct access to a Controller.  If this
> means you have to bundle up a larger amount of data in the Controller so
> the data passage is clean, so be it, that is the lesser evil. -- Darren
> Duncan
>
>
> On 2016-03-09 11:03 AM, Chris Welch wrote:
>
>> Hi
>>
>> This is more of a general MVC question, but hopefully it's okay to ask in
>> here.
>>
>> I've set up a model to generate data in iCal format (see my previous
>> thread and
>> thanks for the responses on that), but it has thrown up an interesting
>> general
>> logic separation question that I don't know the answer to.
>>
>> By way of an example, I'm generating iCal events for a data table called
>> team_matches (DBIx::Class model name TeamMatch).  I was hoping, as would
>> seem to
>> be the cleanest way to do it, to have a result class "helper" method,
>> such that
>> on each match object I could call something like:
>> $match->generate_ical_data,
>> which would generate a hashref of calendar values to be passed through to
>> my
>> MyApp::Model::ICal module that will generate the actual data.  The
>> problem with
>> this is that certain properties require access to the Catalyst
>> application: for
>> example, there's a uri property, the value for which will need to be
>> generated
>> by $c->uri_for_action and since this particular application has the
>> ability to
>> be multi-language (via CatalstX::I18N) the description value needs to be
>> generated by $c->maketext.
>>
>> All of this brings up a quandary: there are only two ways around this
>> that I can
>> see:
>>* Pass $c into the $match->generate_ical_data method (which I know is
>> STRONGLY discouraged and very very bad).
>>* Generate the hashref in the controller (which potentially makes for a
>> 'fatter' controller than you ideally want and I'm trying to stick to the
>> ideals
>> here).
>>
>> I'm guessing the preference of the above options should really be the
>> latter
>> (which is what I'm currently doing in the interim), but I am hoping that
>> there's
>> a super-clever way that I've not thought of that someone can tell me I've
>> completely overlooked?
>>
>> Thank you in advance.
>>
>>
>> Chris
>>
>
>
> ___
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] An MVC logic separation conundrum

2016-03-09 Thread Chris Welch
Hi

This is more of a general MVC question, but hopefully it's okay to ask in
here.

I've set up a model to generate data in iCal format (see my previous thread
and thanks for the responses on that), but it has thrown up an interesting
general logic separation question that I don't know the answer to.

By way of an example, I'm generating iCal events for a data table called
team_matches (DBIx::Class model name TeamMatch).  I was hoping, as would
seem to be the cleanest way to do it, to have a result class "helper"
method, such that on each match object I could call something like:
$match->generate_ical_data, which would generate a hashref of calendar
values to be passed through to my MyApp::Model::ICal module that will
generate the actual data.  The problem with this is that certain properties
require access to the Catalyst application: for example, there's a uri
property, the value for which will need to be generated by
$c->uri_for_action and since this particular application has the ability to
be multi-language (via CatalstX::I18N) the description value needs to be
generated by $c->maketext.

All of this brings up a quandary: there are only two ways around this that
I can see:
  * Pass $c into the $match->generate_ical_data method (which I know is
STRONGLY discouraged and very very bad).
  * Generate the hashref in the controller (which potentially makes for a
'fatter' controller than you ideally want and I'm trying to stick to the
ideals here).

I'm guessing the preference of the above options should really be the
latter (which is what I'm currently doing in the interim), but I am hoping
that there's a super-clever way that I've not thought of that someone can
tell me I've completely overlooked?

Thank you in advance.


Chris
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] New view: ICal?

2016-03-04 Thread Chris Welch
Thanks for the reply - may I ask what the model would be doing, given that
presumably it would have to go through a view in the end anyway?  Because
the data itself already exists in a model, all I'm wanting to do
effectively is extract that and display it in a slightly different format,
so I'm surprised that another model is the way to go - but then I've sort
of been learning as I go with this stuff, so I may well be missing
something fundamental!

Thanks
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] New view: ICal?

2016-03-03 Thread Chris Welch
Hi

So as part of my sports league web site, I've been looking at adding the
ability to download matches into personal calendars.  It strikes me the
most obvious way to do this is with a view, something like
Catalyst::View::ICal - there doesn't seem to be anything like that around
at the moment, so based on the fact that I've never actually contributed
anything to CPAN before (I know that bit is beyond the scope of this list,
I'm looking into that at the moment) I'm sort of thinking it might be
something handy to add in, what do you folks think?

It should be pretty simple even for someone like me, as I think I can use
Data::ICal  to
do most of the work... but is it a reasonable idea and is a view the best
way to do it in any case?  I've had a look through the Catalyst::View::*
modules and couldn't see anything similar, which probably means the idea is
a load of rubbish or no one has had need for it yet I guess - if it's the
former I won't be offended if people tell me so... :-)

Ta


Chris
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Feasibility questions ref transition to Catalyst

2016-03-02 Thread Chris Welch
I know you folks are talking about Apache, but I've used this for nginx for
static content if it helps anyone (I think I'm an nginx convert now mainly
because, it's extremely simple for a relative Linux newbie like me):

location /robots.txt {
  alias /path/to/robots.txt;
  expires 30d;
}

On 2 March 2016 at 10:24, Andrew  wrote:

> Cool, =D.
>
> Thanks for that.
>
>
> - Original Message -
> *From:* QE :: Felix Ostmann 
> *To:* The elegant MVC web framework 
> *Sent:* Wednesday, March 02, 2016 10:01 AM
> *Subject:* Re: [Catalyst] Feasibility questions ref transition to Catalyst
>
> Uh, i guess in some old wiki is that already mentioned. We use this for
> our static content:
>
> Alias /static/ /path/to/static/directory
> Alias / /path/to/myapp_fastcgi.pl/
>
> And in our app we use Static::Simple with the same directory. So while
> developing only with the buildin server all works fine and later apache
> serves the static content and all works fine :)
>
> Mit freundlichen Grüßen
> Felix Ostmann
>
> _
>
> QE GmbH & Co. KG
> Martinistraße 3
> 49080 Osnabrück
> Deutschland
>
> Tel.: +49 (0) 541 / 40666 11 <%2B49%20%280%29%20541%20%2F%2040666%2011>
> Fax: +49 (0) 541 / 40666 22 <%2B49%20%280%29%20541%20%2F%2040666%2022>
> Email: i...@qe.de
> Web: www.qe.de
>
> Unsere Geschäftszeiten:
> Montag bis Freitag von 8 bis 16 Uhr
>
> Firmensitz: Osnabrück
> AG Osnabrück - HRA 200252
> Steuer-Nr.: 66/204/54104
> Ust-IdNr.: DE814737310
>
> Komplementärin:
> QE24 GmbH
> AG Osnabrück - HRB 200359
> Geschäftsführer: Ansas Meyer
> _
>
>
> Die in dieser Email enthaltenen Informationen sind vertraulich
> zu behandeln und ausschließlich für den Adressaten bestimmt.
> Jegliche Veröffentlichung, Verteilung oder sonstige in diesem
> Zusammenhang stehende Handlung wird ausdrücklich untersagt.
>
> 2016-03-02 8:39 GMT+01:00 Andrew :
>
>> Just discovered something else that's pretty cool.
>>
>> When setting up FastCGI in Apache,
>> you have something like:
>>
>> 
>> FastCgiExternalServer
>> /home/username/public_html/myapp/script/myapp_fastcgi.pl -host
>> www.mydomain.com:55900
>> Alias / /home/username/public_html/myapp/script/myapp_fastcgi.pl/
>> 
>>
>> ...in your virtual host configuation.
>> (Because I have CPanel on my Apache server, I'm not editing the httpd.conf
>> file directly. Rather the httpd.conf file links to some include files, so
>> I
>> just edit the include files.)
>>
>> I realised the Alias bit, was making any URL from the domain name, go to
>> the
>> Catalyst Web App.
>> However I had a few old CGIs I wanted to run.
>> I played about a bit, trying to copy and paste the CGI code into a new
>> Catalyst Controller... but I thought: "This is too much work".
>>
>> The CGIs I wanted to run were in a directory - let's pretend the directory
>> was literally called "directory".
>> I added a new Alias line to this part of the Apache configuration:
>>
>> 
>> FastCgiExternalServer
>> /home/username/public_html/myapp/script/myapp_fastcgi.pl -host
>> www.mydomain.com:55900
>> Alias /directory /home/username/public_html/directory
>> Alias / /home/username/public_html/myapp/script/myapp_fastcgi.pl/
>> 
>>
>> .Now...if the url is www.mydomain.com/directory it goes to the
>> directory
>> folder in my public_html folder, and serves it just as apache always did,
>> including running the index.pl file I had there - a cgi perl script no
>> less!
>> Everything else starting with www.mydomain.com gets sent to my new
>> Catalyst
>> Web App.
>>
>> In short - you can setup apache aliases, to still run some CGIs in
>> specific
>> places, while all other URLs run your new Catalyst Web App, =).
>>
>> That means you can have old CGI scripts and your new Catalyst web app,
>> running at the same domain name.
>> As long as there's no conflict of names. I.e. any Catalyst subroutine
>> designed to be triggered by the 'directory' path, won't get triggered, as
>> you've redirected all such requests to your directory folder instead.
>>
>> I simply added a one line alias to achieve this. If there are better ways
>> to
>> run your old CGIs on the same server as your new Catalyst app, I'm happy
>> to
>> hear suggestions, =).
>>
>> One idea that popped into my head was to maybe setup a subdomain that
>> isn't
>> setup with fastcgi, and have all your old CGIs at the sub domain, running
>> as
>> they normally would, on what's a normal apache subdomain. And then have
>> your
>> Catalyst web app running at the normal web domain.
>> So if your CGIs were part of your old website,
>> you could have your new catalyst website at http://www.mydomain.com and
>> your
>> old cgi website at http://old.mydomain.com
>> Then you wouldn't have the conflict of names problem.
>> http://www.mydomain.com/directory
>> and
>> http://old.mydomain.com/directory
>> ...could both give different responses.
>>
>> Some food for thought, =).
>>
>> Yours,
>> Andrew.
>>
>>
>>
>> 

Re: [Catalyst] UK hosting

2016-01-12 Thread Chris Welch
Thank you all very much, I have a decent list to consider now.
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] UK hosting

2016-01-11 Thread Chris Welch
Hello

This is not actually a technical request, so apologies if I shouldn't be
asking this here.

I'm hoping some of you can recommend a host - I've got my site to a point
where I need to think about putting it online somewhere.  It's a rewrite of
a current site, which I wrote 10 years ago when I was learning Perl and
that does a maximum of 500MB bandwidth a month, so I don't think I'd need
any more than 1GB to be safe, but I don't know what sort of server specs I
ought to be going for with a database (MySQL) driven site (my current one
uses dbm hashes).

I've had a look at the (Google cached, as it seems to be down at the
moment) hosting page on the Catalyst wiki and most of the reviews aren't
very recent, so it would be handy to know if there are any up-to-date
recommendations.  I don't necessarily need UK based hosting, but something
that's reasonably responsive for UK-based visitors.  My current site is
hosted here: https://krystal.co.uk/ - I have always been happy with them,
but the requirement to move to VPS to host the Catalyst app means I need to
shop around a bit - their VPS costs don't seem to offer as much as some of
the others.

This is a local sports league website, so I don't have a huge amount of
money to play with - I think I can persuade them to spend about £10-15 a
month.

Thank you in advance.


Chris
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] I18N: language directory with multiple files

2015-09-07 Thread Chris Welch
Hi

I wonder if anyone can help me, I have Catalyst::Plugin::i18N installed and
working okay, but the language files are going to get VERY unwieldy if I
keep everything in a single en_gb.po file (for example) - I was wondering
if there's some way of having something lile the subdirectories of I18N
named for the language tags and then all files directly under read in for
that language if that makes sense?

So instead of having:

lib/I18N/en_gb.po
 fr.po
 etc.

I could have something like

lib/I18N/en_gb/*.po
 fr/*.po

Thank you very much in advance for any help.


Chris
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/