1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<?php
require_once("include/init.inc");
require_once("scripts/include/script.inc");
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:codesearch="http://www.google.com/codesearch/schemas/sitemap/1.0">
<?php
/* Get the number of scripts. */
$scriptcount = getScriptCount();
/* for TESTING: only use the first 10 */
/* $scriptcount = 10; */
/* Loop over all the script IDs. */
for ($script_id = 0; $script_id < $scriptcount; $script_id++) {
$versions = loadScriptVersions($script_id);
/* Loop over all the versions of this script. */
for ($ver = 0; $ver < sizeof($versions); $ver++) {
$source_data = $versions[$ver];
$package = $source_data{'package'};
$len = strlen($package);
/* Only use the entry if there is a package name and it ends in .zip, .vim
* or something like that. */
if ($package != '' && $len > 4) {
/* Newest one has priority 1, older ones lower priority. */
$pri = (sizeof($versions) - $ver) / sizeof($versions);
$date = date('Y-m-d', $source_data{'creation_date'});
$suffix = substr($package, $len - 4, 4);
if (strcasecmp($suffix, ".txt") == 0) {
/* Skip text files (probably documentation). */
continue;
} else if (strcasecmp($suffix, ".zip") == 0
|| strcasecmp($suffix, ".tar") == 0
|| strcasecmp($suffix, ".tgz") == 0
|| strcasecmp($suffix, ".tbz") == 0
|| ($len > 5 && strcasecmp(substr($package, $len - 5, 5), ".tbz2") == 0)
|| ($len > 6 && strcasecmp(substr($package, $len - 6, 6), ".tar.z") == 0)
|| ($len > 7 && strcasecmp(substr($package, $len - 7, 7), ".tar.gz") == 0)
|| ($len > 8 && strcasecmp(substr($package, $len - 8, 8), ".tar.bz2") == 0)
) {
$type = "archive";
} else if (strcasecmp(substr($package, $len - 3, 3), ".pm") == 0) {
/* Someone uploaded a Perl script... */
$type = "perl";
} else if (strcasecmp(substr($package, $len - 3, 3), ".py") == 0) {
/* ... and someone uploaded a Python script... */
$type = "python";
} else if (strcasecmp($suffix, ".tcl") == 0) {
/* ... and someone uploaded a Tcl script... */
$type = "tcl";
} else {
/* Catch-all: the site is for Vim scripts, so assume that everything
* that is not an archive is a Vim script. ".vim.gz" should be OK.
* ".vba" and ".vbz.gz" are Vimball scripts (not Visual basic). */
$type = "vim";
}
?>
<url>
<loc>http://www.vim.org/scripts/download_script.php?src_id=<?=$source_data{'script_source_id'}?></loc>
<codesearch:codesearch>
<codesearch:filetype><?=$type?></codesearch:filetype>
<codesearch:filename><?=$source_data{'package'}?></codesearch:filename>
</codesearch:codesearch>
<priority><?=$pri?></priority>
<lastmod><?=$date?></lastmod>
</url>
<?php
}
}
}
?>
</urlset>
<?php
/* vim: set sw=2 sts=2 fo-=b : */
?>
|