Skip to content

Commit

Permalink
Add descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonXLF committed Apr 27, 2024
1 parent ceb0cb9 commit 3d5f7d8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
12 changes: 11 additions & 1 deletion api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,36 @@
exit;
}

$description = "API for getting the number of links to any page on any Mediawiki project."

?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Link Count API</title>
<meta name="description" content="<?php echo $description; ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/png" href="../static/icon.png">
<style>
body {
font-family: sans-serif;
line-height: 1.5;
}
h2, h3 {

h2,
h3 {
margin: 0 0 10px;
}

p,
ul {
margin: 0 0 20px
}

li {
padding: 2px 0;
}

code {
background: #eee;
font-family: inherit;
Expand All @@ -40,6 +49,7 @@
</head>
<body>
<h1>Link Count API</h1>
<p><?php echo $description; ?></p>
<h2>Request</h2>
<?php echo (new APIHelpObject(
['page', 'string', 'required', 'Name of the page to get the link count for.'],
Expand Down
4 changes: 3 additions & 1 deletion includes/LinkCount.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

class LinkCount implements HtmlProducer, JsonProducer {
public static $description = "View the number of links (wikilinks, redirect, transclusions, file links, and category links) to any page on any Wikimedia project.";

public $counts;
public string $error;

Expand Down Expand Up @@ -128,7 +130,7 @@ public function getHtml() {
}

if (!isset($this->counts)) {
return '';
return LinkCount::$description;
}

$validCounts = array_filter($this->counts, function($val) {
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<html lang="en">
<head>
<title><?php echo $linkCount->getTitle(); ?></title>
<meta name="description" content="<?php echo LinkCount::$description; ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="js/" defer></script>
<link rel="stylesheet" href="node_modules/oojs-ui/dist/oojs-ui-wikimediaui.min.css">
Expand Down
2 changes: 1 addition & 1 deletion tests/LinkCountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ public function provideHtmlOutput() {
],
'no parameters' => [
'',
'',
'View the number of links (wikilinks, redirect, transclusions, file links, and category links) to any page on any Wikimedia project.',
''
],
'no title (error)' => [
Expand Down

0 comments on commit 3d5f7d8

Please sign in to comment.