Skip to content

Commit

Permalink
Make it work after upstream changes
Browse files Browse the repository at this point in the history
The workflow was no longer working due to upstream CDN changes.
See freeCodeCamp/devdocs#1317
  • Loading branch information
rchl committed Mar 13, 2021
1 parent ef5fd37 commit 4bec159
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/scripts/conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
class DevDocsConf {

private static $baseUrl = 'https://devdocs.io/';
private static $docUrl = 'https://docs.devdocs.io/';
private static $cacheDirectory = 'cache/';

private $commands = ['add' => 1, 'remove' => 1, 'refresh' => 1, 'list' => 1, 'alias' => 1, 'unalias' => 1, 'select' => 0, 'addAll' => 0, 'nuke' => 0];
Expand Down Expand Up @@ -270,7 +269,7 @@ private function refreshCmd() {
foreach ($docToUpdate as $doc) {
file_put_contents(
self::$cacheDirectory . $doc->slug . '.json',
$this->workflows->fetch(self::$docUrl . $doc->slug . '/index.json')
$this->workflows->fetch(self::$baseUrl . 'docs/' . $doc->slug . '/index.json')
);
}
echo (($updateAll) ? 'All data docs' : $this->currentCmd[1] . ' doc') . ' updated!';
Expand Down
5 changes: 2 additions & 3 deletions src/scripts/devdocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
require_once 'workflows.php';

class DevDocs {
private static $docUrl = 'http://docs.devdocs.io/';
private static $cacheDirectory = 'cache/';

private $workflows;
Expand Down Expand Up @@ -76,8 +75,8 @@ private function checkCache($documentation) {
error_log("Checking existence of cache at $docFile");
// Keep the docs in cache before expired
if (!file_exists($docFile) || ($this->cacheLife >= 0 && filemtime($docFile) <= time() - 86400 * $this->cacheLife)) {
error_log("Download doc for $documentation at \"" . self::$docUrl . $documentation . '/index.json') . "\"";
file_put_contents($docFile, file_get_contents(self::$docUrl . $documentation . '/index.json'));
error_log("Download doc for $documentation at \"" . self::$baseUrl . 'docs/' . $documentation . '/index.json') . "\"";
file_put_contents($docFile, file_get_contents(self::$baseUrl . 'docs/' . $documentation . '/index.json'));
}
}

Expand Down

0 comments on commit 4bec159

Please sign in to comment.