Page MenuHomePhabricator

Add configuration parameter to enable use of 'Vertical header' template
Open, Needs TriagePublicFeature

Description

Proposal: Not too long ago I ported the 'Vertical header' Lua module and wiki template from English Wikipedia to Wikidata, with an eye towards submitting a PR on GitHub which would implement a boolean parameter controlling its use when inteGraality is constructing the table column headers of its reports. Alas, though, my free time is more scarce than ever lately (and my Python skills or lack thereof creating a bigger chore of it than needs be) so I thought I would at least file this record of my intended enhancement and the rationale for it here so that it can at least be vetted for suitability, and perhaps even brought to fruition.

It seems to me that the report tables generated by inteGraality would make much better use of space if only the column headers could be less wide. Thinking that the Vertical header template I'd first encountered on enwiki would be eminently suited to the task, after porting it I tested the impact manually on a table made for WikiProject Podcasts. Here is the "before" link, and now here it is again with the same data, but the headers rotated 90° counterclockwise. To my mind this provides several benefits, obviously the more compact layout allows for more information to be conveyed without the need for scrolling along either axis, but it also allows for greater freedom in defining the column titles, greatly reducing the formatting penalty for more descriptive titles and making the information more accessible to those lacking familiarity with the dataset under analysis.

Implementation: From what I've been able to divine, I believe the changes to the codebase would be fairly straight-forward, at least in column.py where the column header output is generated, probably resembling something like...

@@ -124,18 +124,24 @@  class PropertyColumn(AbstractColumn):
     def make_column_header(self):
         if self.qualifier:
             property_link = self.qualifier
         else:
             property_link = self.property

         if self.title:
-            label = f'[[Property:{property_link}|{self.title}]]'
+            if self.vertical:
+                label = f'{{{{Vertical header|sortable=yes|unbold=yes|[[Property:{property_link}|'''{self.title}'''<br /><small>({property_link})</small>]]}}}}'
+            else:
+                label = f'| [[Property:{property_link}|{self.title} <small>({property_link})</small>]]'
         else:
-            label = f'{{{{Property|{property_link}}}}}'
-        return f'! data-sort-type="number"|{label}\n'
+            if self.vertical:
+                label = f'{{{{Vertical header|sortable=yes|unbold=yes|{{{{Property|{property_link}}}}}}}}}'
+            else:
+                label = f'| {{{{Property|{property_link}}}}}'
+        return f'! data-sort-type="number" {label}\n'

     def get_filter_for_info(self):
         if self.qualifier:
             property_value = f'wd:{self.value}' if self.value else '[]'
             return f"""
     ?entity p:{self.property} [ ps:{self.property} {property_value} ; pq:{self.qualifier} [] ]"""
         else:

I tweaked your existing arrangement for building the 'label' variable in order to make it more uniform with the output of the Property template, but that's more a matter of taste and not relevant to the other changes I'm proposing. I'm interested to hear some feedback and will still attempt to cobble together a PR by myself, provided none of the stakeholders lodges any serious objection. Thanks for all the work you've put into making a really nifty tool! 😎