Opened 10 years ago

Closed 9 years ago

#2593 closed defect (fixed)

Use GRASS GIS 7 for module of the day

Reported by: wenzeslaus Owned by: grass-dev@…
Priority: normal Milestone: Website
Component: Website Version: unspecified
Keywords: php Cc:
CPU: Unspecified Platform: Unspecified

Description

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.)

Change History (15)

comment:1 by neteler, 10 years ago

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

comment:2 by neteler, 10 years ago

Keywords: php added

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

comment:3 by wenzeslaus, 9 years ago

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

in reply to:  3 ; comment:4 by neteler, 9 years ago

Replying to wenzeslaus:

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

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

in reply to:  4 ; comment:5 by neteler, 9 years ago

Replying to 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.

in reply to:  5 comment:6 by neteler, 9 years ago

Replying to neteler:

Likely a backport of r65438 would fix this issue.

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

in reply to:  1 ; comment:7 by wenzeslaus, 9 years ago

Good to see the modules back.

Replying to 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.

in reply to:  7 ; comment:8 by neteler, 9 years ago

Replying to 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

in reply to:  8 ; comment:9 by wenzeslaus, 9 years ago

Replying to neteler:

Replying to 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?

in reply to:  9 comment:10 by neteler, 9 years ago

Replying to 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

comment:11 by wenzeslaus, 9 years ago

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

- 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):

- $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 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?

in reply to:  11 comment:12 by neteler, 9 years ago

Replying to 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 simply all in the CMS ("user defined tags").

Last edited 9 years ago by neteler (previous) (diff)

comment:13 by neteler, 9 years ago

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

comment:14 by wenzeslaus, 9 years ago

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

        $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.

comment:15 by neteler, 9 years ago

Resolution: fixed
Status: newclosed

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

Thanks, Vaclav.

Note: See TracTickets for help on using tickets.