User:Dapete/Catgraph
From Meta, a Wikimedia project coordination wiki
Contents |
[edit] Deutsch
Catgraph ist ein Toolserver-Tool, um Kategorienstrukturen graphisch darzustellen. Es zeichnet ein Diagramm, bei dem unten die angegebene Kategorie steht und darüber deren Überkategorien.
[edit] Verwendung
Am einfachsten zu verwenden ist Catgraph vom Formular unter http://toolserver.org/~dapete/catgraph/ aus. Es ist auch möglich, es unter http://toolserver.org/~dapete/catgraph/graph.php direkt anzusprechen und die Parameter als Query-String (Artikel ist etwas dürftig, besser in en.WP unter query string nachlesen) anzugeben.
Die Parameter sind:
- Wiki
- (Parameter
wiki=…im Query-String, muss angegeben werden) bestimmt, welches Wiki verwendet wird. Angegeben werden könnenwikipedia,wikinewsusw. sowiecommonsfür Wikimedia Commons undmetafür das Meta-Wiki. - Sprache
- (
lang=…) bestimmt, welche Sprache verwendet wird. Muss bei allen mehrsprachigen Wikis angegeben werden, bei Commons und Meta hat es keine Funktion. Anzugeben ist der übliche Sprachcode (de,enusw.) - Kategorie
- (
cat=…, muss angegeben werden) bestimmt die Kategorie, deren Überkategorien angezeigt werden. - Maximale Tiefe
- (
d=…, Standard ist unbegrenzt) bestimmt, wie tief Catgraph in der Kategorienstruktur sucht. Wenn dieser Parameter nicht angegeben oder auf0gesetzt wird gibt es kein Tiefenlimit. Allerdings beschränkt der nächste Parameter trotzdem die Tiefe: - Maximale Kategorien
- (
n=…, Standard ist bei Dateiformat "dot" unbegrenzt, sonst100) bestimmt, wieviele Kategorien insgesamt angezeigt werden. Das wird erreicht, indem die maximale Suchtiefe so beschränkt wird, dass nicht mehr als die gegebene Anzahl Kategorien angezeigt wird. Bei Ausgabe im "dot"-Dateiformat ist Standard0(unendlich), bei allen anderen Dateiformaten gibt es aus Performancegründen eine feste Obergrenze von100, die auch Standard ist. - Dateiformat
- (
format=…, Standard istpng) bestimmt, welches Dateiformat erstellt wird. Optionen sindpng(Standard),gif,pdfundsvgsowiedot(der "Quellcode" des Graphen). - Links
- (
links=…, Standard ist nein) bestimmt, ob das erstellte Bild Links enthält. Ein Wert von0bedeutet nein. Der Wertgraph(oder1, zur RÜckwärtskompatibilität) erstellt Links zum Catgraph für jede andere Kategorie,wikiLinks auf die Kategorie im Wiki. Für die Dateiformatepngundgiferzeugt diese Option eine HTML-Seite, die nur ein Bild mit einer Verweissensitive Grafik (Image map) enthält. Beisvgsind die Links im Bild selbst enthalten, beipdfhat die Option keine Wirkung. - Kategorien zeigen
- (
sub=…, Standard ist Überkategorien) bestimmt, ob die Über- oder die Unterkategorien der angegebenen Kategorie angezeigt werden. Der Wert0(Standard) zeigt die Überkategorien an, ein Wert von1die Unterkategorien. - Kleines Bild erstellen
- (
small=…, Standard ist0) erzeugt bei einem Wert von1ein deutlich kleineres Bild, unter anderem durch reduzierte Schriftgröße. Es ist für mobile Geräte gedacht (konkret hatte ist die PSP im Sinn), auf denen nicht so viel Platz ist und auf denen kleine Bilder meist auch gut lesbar sind.
[edit] Unterstütze Schriftsysteme
Siehe Abschnitt Supported scripts (englisch).
[edit] Technisches
Die Daten werden aus der Toolserver-Datenbank zusammengetragen. Das geschieht inkrementell: erst werden die direkten Überkategorien gelesen, dann die Überkategorien dieser Überkategorien usw. bis entweder die gesetzte Zahl an Kategorien oder die Suchtiefe erreicht wird.
Diese Daten werden dann benutzt, um eine DOT-Datei zu erstellen, die an Graphviz (dot) weitergereicht wird, um ein Bild des Diagramm zu erzeugen.
Der Quellcode ist hier verfügbar.
[edit] English
Catgraph is a Toolserver tool to visualize category structures. It draws a diagram with a specified category at the bottom and its supercategories above.
[edit] Usage
The easiest way to use Catgraph is from the form at http://toolserver.org/~dapete/catgraph/. It is also possible to directly access http://toolserver.org/~dapete/catgraph/graph.php and supply the parameters as the query string.
The parameters are:
- Wiki
- (parameter
wiki=…in the query string, mandatory) determines which wiki is used. Options arewikipedia,wikinewsetc. as well ascommonsfor Wikimedia Commons andmetafor the Meta Wiki. - Language
- (
lang=…) determines which language is used. Mandatory for all multi-language wikis, no function with Commons and Meta. You have to supply the usual language code (en,deetc.). - Category
- (
cat=…, mandatory) determines the category whose supercategories will be shown. - Maximum depth
- (
d=…, defaults to unlimited) determines how deep Catgraph will "dig" into the structure. If not supplied, or set to0, there is no depth limit. However the next parameter still limits the depth: - Maximum categories
- (
n=…, defaults to unlimited for "dot" output, otherwise to100) determines how many categories in total will be shown. This is achieved by limiting the maximum depth such that no more than the set number of categories is shown. For "dot" output, the default is0(unlimited), for all other output formats there is a hard limit of100categories for performance reasons, which is also the default. - File format
- (
format=…, defaults topng) determines what file format will be created. Options arepng(default),gif,pdfandsvgas well asdot(the "source code" of the graph). - Links
- (
links=…, defaults to no) determines whether the resulting image has links. No value or0means no. A value ofgraph(or1for backwards compatibility) creates links to the Catgraph for each other category,wikicreates a link to the category in the wiki. For file formatspngandgif, this creates an HTML page containing just an image with an image map. Forsvg, the links are embedded directly in the image. Forpdf, the option has no effect. - Show categories
- (
sub=…, defaults to supercategories) determines whether the supercategories or the subcategories of the given category are shown. A value of0(default) shows the supercategories, a value of1shows the subcategories. - Create small image
- (
small=…, defaults to0) when set to1creates a significantly smaller image using a smaller font, among other things. It's intended for mobile devices (I was thinking of the PSP when I wrote it) which have small screens but display small images in a readable way, anyway.
[edit] Supported scripts
The fonts used for the creation of the image do not support all scripts. All those with Roman and Cyrillic letters should work, but I have also tried the following languages - if there are other languages using the same or similar scripts these should work, too:
- Arabic
- Armenian
- Georgian
- Greek
- Hebrew
- Hindi
- Inuktitut (this must be the most unusual language supported)
- Kurdish
- Thai
The following languages don't work and other languages with the same or similar scripts will probably not work either:
- Chinese
- Japanese
- Korean
This applies mostly to GIF and PNG because these depend on the toolserver having the right font; SVGs and, perhaps, PDFs could display correctly either because your system finds a font that supports the script, or if you manually edit the files to change the font to one supporting the needed characters.
[edit] Technical aspects
The data is gathered from the Toolserver's database. This is incremental: first the direct supercategories are fetched, then the supercategories of these supercategories, etc. until either the set number of categories or the search depth are reached.
This data is then used to create a DOT graph definition, which is fed to Graphviz' dot program to render an image from it.
The source code is available here.
[edit] Notes
- Perhaps also allow a graph "between two categories"?