Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions merge_repo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""Merge dat/repo/*.json into a single repo.json for the /repo/ endpoint."""

import json
import os
import sys

src_dir = sys.argv[1] if len(sys.argv) > 1 else 'site/dat/repo'
dest = sys.argv[2] if len(sys.argv) > 2 else 'upload/dat/repo/repo.json'

plugins = []
for f in sorted(os.listdir(src_dir)):
if f.endswith('.json'):
with open(os.path.join(src_dir, f)) as fh:
plugins.extend(json.load(fh))

os.makedirs(os.path.dirname(dest), exist_ok=True)
with open(dest, 'w') as fh:
json.dump(plugins, fh)

print(f'Merged {len(plugins)} plugins from {src_dir} into {dest}')
3 changes: 3 additions & 0 deletions prepare-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ cp -r site/build/* upload/
# Examples
cp -r examples upload/img/

# Merge repo JSON files into single file
python merge_repo.py

# PHP for /repo/ endpoint (stays dynamic)
cp site/index.php upload/
cp site/cfg.php upload/
Expand Down
37 changes: 13 additions & 24 deletions site/JPGC/PluginsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,42 @@ class PluginsRepository extends PWEModule implements Outputable
{
public function process()
{
$plugins = $this->getRepoData(true);
if ($_POST['stats'] && $_POST['stats'] != 'null') {
PWELogger::warn("Status: %s", $_POST['stats']);
throw new HTTP2xxException("", HTTP2xxException::OK);
} else {
PWELogger::warn("Status: [%s]", $_REQUEST['installID']);
}

$repoFile = $this->getRepoFile();
$max_age = 8 * 3600;
$this->PWE->sendHTTPHeader("Cache-Control: public, max-age=$max_age", true);
$this->PWE->sendHTTPHeader("Content-Type: application/json", true);
$this->PWE->sendHTTPHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($repoFile)) . ' GMT', true);

if ($_REQUEST['id']) {
$plugins = json_decode(file_get_contents($repoFile), true);
foreach ($plugins as $plugin) {
if ($plugin['id'] == $_REQUEST['id']) {
$plugins = array($plugin);
break;
throw new HTTP2xxException(json_encode(array($plugin)));
}
}
}

$max_age = 8 * 3600;
$this->PWE->sendHTTPHeader("Cache-Control: public, max-age=$max_age", true);
$this->PWE->sendHTTPHeader("Content-Type: application/json", true);
throw new HTTP2xxException(json_encode($plugins));
throw new HTTP2xxException(file_get_contents($repoFile));
}

private function getRepoData($readFiles = false)
private function getRepoFile()
{
$node = $this->PWE->getNode();
$configsDir = $node['!a']['configs'];
if (!$configsDir || !is_dir($configsDir)) {
throw new HTTP5xxException("Configs dir don't exist: " . realpath($configsDir));
}

$plugins = [];
$oldest = 0;
foreach (scandir($configsDir) as $fname) {
if ($fname[0] == '.') {
continue;
}
$full_name = $configsDir . '/' . $fname;
$oldest = max($oldest, filemtime($full_name));
if ($readFiles) {
$set = json_decode(file_get_contents($full_name), true);
$plugins = array_merge($plugins, $set);
}
$repoFile = $configsDir . '/repo.json';
if (!is_file($repoFile)) {
throw new HTTP5xxException("Repo file not found: " . realpath($repoFile));
}

$this->PWE->sendHTTPHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s', $oldest) . ' GMT', true);
return $plugins;
return $repoFile;
}
}
67 changes: 1 addition & 66 deletions site/dat/out.xml
Original file line number Diff line number Diff line change
@@ -1,68 +1,3 @@
<url title="JMeter Plugins" template="dat/plugins.tpl"
keywords="jmeter, plugins, load, performance, analysis, graphs, hadoop, webdriver, selenium"
description="A custom set of plugins for Apache JMeter, not affiliated with Apache Software Foundation, graphs, load shapers, new functions."
class="PWE\Modules\HTMLPage\HTMLPage" src="catalogue.html">

<url link="get" class="PWE\Modules\RedirectAccepted\RedirectAccepted"
base="https://search.maven.org/remotecontent?filepath=kg/apc/jmeter-plugins-manager/1.12/jmeter-plugins-manager-1.12.jar"
no_final_slash="1"/>

<url link="install" title="Install" menu="1" ico="fa-download"
class="PWE\Modules\SimpleWiki\SimpleWiki" wiki_dir="wiki" single_page="Install" accept="1"
syntax="PWE\Modules\SimpleWiki\GitHubMarkdownSyntax\Config" wiki_file_ext="md"
/>

<url link="catalogue" title="Browse Plugins" menu="1" ico="fa-search"
class="PWE\Modules\RedirectAccepted\RedirectAccepted" accept="1" base=""
/>

<url link="downloads" title="Download" menu="0" class="PWE\Modules\SimpleWiki\SimpleWiki" wiki_dir="dl"
start_page="all" files_base="files" download_link="../file" accept="1" ico="fa-download">
<url link="file" files_base="files" class="PWE\Modules\FileDownloads\FileDownloads" accept="2"/>
<url link="all" class="PWE\Modules\RedirectAccepted\RedirectAccepted" no_final_slash="1"
base="/install/Install/"/>
</url>

<url link="wiki" class="PWE\Modules\SimpleWiki\SimpleWiki" wiki_dir="wiki" start_page="Start" ico="fa-book"
files_base="files" download_link="../../downloads/file"
syntax="PWE\Modules\SimpleWiki\GitHubMarkdownSyntax\Config" wiki_file_ext="md"
accept="1" menu="1" title="Documentation">
<url link="WeightedSwitchController" class="PWE\Modules\RedirectAccepted\RedirectAccepted" no_final_slash="1"
base="https://github.com/Blazemeter/jmeter-bzm-plugins/blob/master/wsc/WeightedSwitchController.md"/>

<url link="RotatingListener" class="PWE\Modules\RedirectAccepted\RedirectAccepted" no_final_slash="1"
base="https://github.com/Blazemeter/jmeter-bzm-plugins/blob/master/rotating-listener/RotatingListener.md"/>

<url link="XMPPSampler" class="PWE\Modules\RedirectAccepted\RedirectAccepted" no_final_slash="1"
base="https://github.com/Blazemeter/jmeter-bzm-plugins/blob/master/xmpp/XMPPSampler.md"/>

<url link="XMPPConnection" class="PWE\Modules\RedirectAccepted\RedirectAccepted" no_final_slash="1"
base="https://github.com/Blazemeter/jmeter-bzm-plugins/blob/master/xmpp/XMPPConnection.md"/>

<url link="DirectoryListing" class="PWE\Modules\RedirectAccepted\RedirectAccepted" no_final_slash="1"
base="https://github.com/Blazemeter/jmeter-bzm-plugins/blob/master/directory-listing/DirectoryListing.md"/>

<url link="LoadosophiaUploader" class="PWE\Modules\RedirectAccepted\RedirectAccepted" no_final_slash="1"
base="https://github.com/Blazemeter/jmeter-bzm-plugins/blob/master/sense-uploader/LoadosophiaUploader.md"/>

<url link="PerfMonAgent" class="PWE\Modules\RedirectAccepted\RedirectAccepted" no_final_slash="1"
base="https://github.com/undera/perfmon-agent"/>

<url link="HadoopSet" class="PWE\Modules\RedirectAccepted\RedirectAccepted" no_final_slash="1"
base="https://github.com/undera/jmeter-hadoop"/>
</url>

<url link="stats" title="Usage Statistics" menu="1" ico="fa-bar-chart"
class="PWE\Modules\HTMLPage\HTMLPage" src="stats.html"/>

<url link="support" menu="1" title="Support Forums" class="PWE\Modules\RedirectAccepted\RedirectAccepted"
base="http://groups.google.com/forum/#!forum/jmeter-plugins" accept="1" ico="fa-support"/>

<url link="editor" menu="1" title="JMX Editor" class="PWE\Modules\RedirectAccepted\RedirectAccepted"
base="/editor/?utm_source=jpgc&amp;utm_medium=banner&amp;utm_campaign=menu" accept="1" ico="fa-pencil-square-o"/>

<url link="sources" title="Source Code" menu="0" ico="fa-github-alt"
class="PWE\Modules\RedirectAccepted\RedirectAccepted" base="https://github.com/undera/jmeter-plugins"/>

<url title="JMeter Plugins">
<url link="repo" class="JPGC\PluginsRepository" configs="dat/repo" template="empty.tpl"/>
</url>
Loading