Skip to content

Instantly share code, notes, and snippets.

@haykuro
Last active August 29, 2015 14:06
Show Gist options
  • Save haykuro/153e553e853453530fed to your computer and use it in GitHub Desktop.
Save haykuro/153e553e853453530fed to your computer and use it in GitHub Desktop.
Gets all the page slugs from the Ultra Music Festival website
<?php
if (isset($_GET['get_the_data'])) {
exit(file_get_contents(hex2bin('687474703a2f2f7777772e756c7472616d75736963666573746976616c2e636f6d2f64622f312e302f6f626a656374732f66696e643f63726974657269613d7b253232736974655f69642532323a2532323534303235303263656439616163333930333637323137612532327d')));
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Get Slugs from ULTRA</title>
</head>
<body>
<button id="the_button">Get all the pages!</button>
<table id="the_table" border=1>
<tr>
<th>slug</th>
<th>created_at</th>
<th>last_modified</th>
</tr>
</table>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
(function ($) {
function make_row ($page) {
var $last_modified = new Date($page.last_modified);
var $last_modified_string = $last_modified.toDateString().concat(" ", $last_modified.toTimeString());
var $created = new Date($page.created);
var $created_string = $created.toDateString().concat(" ", $created.toTimeString());
var slug = $page.slug;
if ($page.collection == 'posts') {
slug = $page.collection + '/' + slug;
}
return "<tr>".concat("\n",
'<td>',
'<a href="http://ultramusicfestival.com/'+slug+'" target="ultra_site">http://ultramusicfestival.com/'+slug+'</a>',
'</td>',
'<td>',
$created_string,
'</td>',
'<td>',
$last_modified_string,
'</td>',
'</tr>'
);
}
var buttonClick = function ($event) {
$.get('?get_the_data=true', function ($data_unparsed) {
$("#the_table tr:not(:has(th))").remove();
$data = JSON.parse($data_unparsed);
$data_unparsed = null;
for ($i in $data) {
$("table").append(make_row($data[$i]));
}
});
};
$("#the_button").on('click', buttonClick);
}(jQuery));
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment