[GRASS-dev] [GRASS GIS] #2593: Use GRASS GIS 7 for module of the day

#2593: Use GRASS GIS 7 for module of the day
-------------------------+--------------------------------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Keywords: | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
Currently GRASS GIS 6 modules are used for module of the day at
http://grass.osgeo.org/. Please update to GRASS GIS 7.

(I noticed because I just got `d.ask`.)

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
-------------------------+--------------------------------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Keywords: | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by neteler):

I have updated it to G70.

But for me it always shows the same module, even in "random" rather than
"day" mode.

Managed in the CMS in:

Extensions -> User defined tags

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
-------------------------+--------------------------------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Keywords: php | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
Changes (by neteler):

  * keywords: => php

Comment:

The PHP code seems to be broken: it should fetch the full_index.html and
then parse it but it does not get any input.

The "module_of_the_day" code is temporarily posted here:
http://pastebin.com/qjGCk3kV

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by wenzeslaus):

It shows `t.rast.accumulate` now for me but the link is broken. The only
temporal module with generated manual is `t.connect`:

  * http://grass.osgeo.org/grass70/manuals/temporal.html

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by neteler):

Replying to [comment:3 wenzeslaus]:
> It shows `t.rast.accumulate` now for me but the link is broken. The only
temporal module with generated manual is `t.connect`:
>
> * http://grass.osgeo.org/grass70/manuals/temporal.html

{{{
GRASS GIS 7.0.1svn r65380 compilation log
--------------------------------------------------
Started compilation: Sat Jun 6 04:20:40 PDT 2015
--
Errors in:
/home/neteler/grass70_svn_relbranch_bin_snapshot/grass70_relbranch/lib/python/pygrass/modules/interface
/home/neteler/grass70_svn_relbranch_bin_snapshot/grass70_relbranch/temporal/t.create
/home/neteler/grass70_svn_relbranch_bin_snapshot/grass70_relbranch/temporal/t.support
/home/neteler/grass70_svn_relbranch_bin_snapshot/grass70_relbranch/temporal/t.topology
...
}}}

I generated a fresh log:

http://grass.osgeo.org/grass70/binary/linux/snapshot/build.log

The issue also here:
{{{
     env = {k.strip(): v.strip() for k, v in [row.split(':')
                                   ^
SyntaxError: invalid syntax
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by neteler):

Replying to [comment:4 neteler]:
> The issue also here:
> {{{
> env = {k.strip(): v.strip() for k, v in [row.split(':')
> ^
> SyntaxError: invalid syntax
> }}}

Likely a backport of r65438 would fix this issue.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by neteler):

Replying to [comment:5 neteler]:
> Likely a backport of r65438 would fix this issue.

It does, r65439 brings the tempral manual back also for G7.0.svn.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by wenzeslaus):

Good to see the modules back.

Replying to [comment:1 neteler]:
> I have updated it to G70.
>
> But for me it always shows the same module, even in "random" rather than
"day" mode.
>
> Managed in the CMS in:
>
> Extensions -> User defined tags

I suppose this is still an issue. I see `t.rast.accumulate` as I saw
yesterday.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by neteler):

Replying to [comment:7 wenzeslaus]:
> I suppose this is still an issue. I see `t.rast.accumulate` as I saw
yesterday.

Yes, because nobody fixed the PHP code... I put it again here for
inspection:

http://pastebin.com/thaWh2Yp

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by wenzeslaus):

Replying to [comment:8 neteler]:
> Replying to [comment:7 wenzeslaus]:
> > I suppose this is still an issue. I see `t.rast.accumulate` as I saw
yesterday.
>
> Yes, because nobody fixed the PHP code... I put it again here for
inspection:
>
> http://pastebin.com/thaWh2Yp

I spent just few seconds looking at it and I lack the context a little bit
but I would say that t.rast.accumulate is hardcoded there. Is that
possible?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by neteler):

Replying to [comment:9 wenzeslaus]:
> I spent just few seconds looking at it and I lack the context a little
bit but I would say that t.rast.accumulate is hardcoded there. Is that
possible?

AFAIK it should be only used as fall-back in case that the index of manual
pages could not be retrieved. For readability, I have reformatted the code
with an online PHP beautifier:

http://pastebin.com/mpSGdCDc

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by wenzeslaus):

Well, the code has a few strange places which would use some refactoring,
but anyway, I think that the change should be applied everywhere:

{{{
#!diff
- while (substr($a[$ra], 0, 27) != "<tr><td valign=top><a href=")
+ while (substr($a[$ra], 0, 29) != "<tr><td valign=\"top\"><a href=")
}}}

This will need to be changed next time the HTML file will be changed, e.g.
replacing attributes by styles or change in formatting. Besides possible
refactoring of this PHP, the complete solution I have in mind for some
time already is to have XML, CSV, JSON and plain text files generated
automatically and available online. These files could be used by tools
like this one (or some interactive manual pages) for searching and showing
info about modules without parsing of HTML which can change anytime.

For the "random" part this should be changed too (just optimization and
avoiding a warning):

{{{
#!diff
- $ra = rand(0, 1000);
+ $ra = rand(0, count($a));
}}}

I'm not sure how the "day" part should be changed if at all, but there are
some magic numbers as well.

BTW, I saved the file and then executed in command line using `php
grass_moday.php`. I had to add `<?php` at the beginning and `?>` at the
end. I also downloaded the
[http://grass.osgeo.org/grass70/manuals/full_index.html full_index.html]
file (`wget http://grass.osgeo.org/grass70/manuals/full_index.html\`\)

BTW2, these things are not in grass-web repository? Why not? Are they too
intimate, i.e. too many strange paths etc.? Or too much management
overhead?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:11&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by neteler):

Replying to [comment:11 wenzeslaus]:
...

well done, I applied both changes and it finally works!
http://grass.osgeo.org/

> BTW2, these things are not in grass-web repository? Why not?

Because that repo was abandoned years ago when we switched to the CMS.

> Are they too intimate, i.e. too many strange paths etc.? Or too much
management overhead?

No, it is simple all in the CMS ("user defined tags").

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2593#comment:12&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by neteler):

Mhh, while the module selection now works, the subdir path is lacking and
the respective manual page not found.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:13&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by wenzeslaus):

Now I see that the first change needs to be applied also in the "find and
replace" part:

{{{
#!diff
         $what = array(
- "<tr><td valign=top><a href=\"",
+ "<tr><td valign=\"top\"><a href=\"",
                 "</a>",
                 "<td>",
                 "</td>"
         );
         $with = array(
- "<tr><td valign=top><a href=\"$fullindex_directory/",
+ "<tr><td valign=\"top\"><a href=\"$fullindex_directory/",
                 "</a>",
                 "<td>",
                 "</td>"
         );
         return "<table>" . str_replace($what, $with, $a[$ra]) .
"</table>";
}}}

What the rest of the items in the array mean, I have no idea.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:14&gt;
GRASS GIS <http://grass.osgeo.org>

#2593: Use GRASS GIS 7 for module of the day
--------------------------+-------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: Website
Component: Website | Version: unspecified
Resolution: fixed | Keywords: php
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by neteler):

* status: new => closed
* resolution: => fixed

Comment:

Evviva - after so many years the "Module of the day" mechanism finally
works.

Thanks, Vaclav.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2593#comment:15&gt;
GRASS GIS <http://grass.osgeo.org>