Skip to content

Commit

Permalink
linting, fix typo & probable #3
Browse files Browse the repository at this point in the history
  • Loading branch information
lerni committed Jun 28, 2023
1 parent 5732bb0 commit 892da10
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Silverstripe FolderIndex
Silverstripe FolderIndex let you manage visibility of files for Search Engines on parent folder basis, by setting X-Robots header-tags `noindex`, `nofollow`, `noimageindex`, `noarchive`, `nosnippet`. By uncheck `ShowInSearch` under `Details` of a folder, headers 'll be set on all files contained, inclusive files in sub-folders. If `gorriecoe/silverstripe-robots` is installed, "unchecked folders" are also disallowed per `robots.txt`.
Silverstripe FolderIndex lets you manage the visibility of files for Search Engines on a parent folder basis, by setting X-Robots header-tags `noindex`, `nofollow`, `noimageindex`, `noarchive`, `nosnippet`. By unchecking `ShowInSearch` under `Details` of a folder, headers will be set on all files contained, including files in sub-folders. If `gorriecoe/silverstripe-robots` is installed, "unchecked folders" are also disallowed per `robots.txt`.

The module also adds `NoFileIndex()` to `File`. This can be used for checking in xml-sitemap, schema etc. and is used in CMS/Assets to indicate, if a file has X-Robots-Tag headers set per parent Folder or parent/parent/etc. If headers are set, it return the Folder-Object that blocks indexing, otherwise false. So far this module just integrates with Apache `.htaccess`.

Expand Down
50 changes: 25 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"name": "lerni/folderindex",
"type": "silverstripe-vendormodule",
"description": "Silverstripe Extension to send noindex, nofollow for files in foldes that do not ShowInSearch.",
"homepage": "https://github.com/lerni/folderindex",
"keywords": ["Silverstripe", "assets", "noindex", "File", "Image"],
"license": "BSD-3-Clause",
"keywords": [
"Silverstripe",
"assets",
"noindex",
"File",
"Image"
],
"homepage": "https://github.com/lerni/folderindex",
"license": "BSD-3-Clause",
"require": {
"silverstripe/asset-admin": "^1.6"
},
"name": "lerni/folderindex",
"type": "silverstripe-vendormodule",
"description": "Silverstripe Extension to send noindex, nofollow for files in foldes that do not ShowInSearch.",
"homepage": "https://github.com/lerni/folderindex",
"keywords": ["Silverstripe", "assets", "noindex", "File", "Image"],
"license": "BSD-3-Clause",
"keywords": [
"Silverstripe",
"assets",
"noindex",
"File",
"Image"
],
"homepage": "https://github.com/lerni/folderindex",
"license": "BSD-3-Clause",
"require": {
"silverstripe/asset-admin": "^1.6"
},
"suggest": {
"gorriecoe/silverstripe-robots": "robots.txt generation for Silverstripe"
},
"autoload": {
"psr-4": {
"Kraftausdruck\\": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
"autoload": {
"psr-4": {
"Kraftausdruck\\Extensions\\": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
3 changes: 1 addition & 2 deletions src/Extensions/FileIndexExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ public function NoFileIndex()
$parentIterInstance = $this->owner->parent();
$counter = 0;
$max = 10;
while($parentIterInstance->ShowInSearch and ($counter < $max)) {
while ($parentIterInstance->ShowInSearch and ($counter < $max)) {
$parentIterInstance = $parentIterInstance->parent();
$counter++;
}
if ($parentIterInstance->ID != 0) {
return $parentIterInstance;
}

} else {
return false;
}
Expand Down
13 changes: 8 additions & 5 deletions src/Extensions/FolderIndexTemplateUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@
use SilverStripe\Core\ClassInfo;
use SilverStripe\View\TemplateGlobalProvider;

class FolderIndexTemplateUtils implements TemplateGlobalProvider {
class FolderIndexTemplateUtils implements TemplateGlobalProvider
{

private static $utility_functions = [
'KraftausdruckFolderIndex'
];

public static function get_template_global_variables() {
public static function get_template_global_variables()
{
return static::$utility_functions;
}

public static function KraftausdruckFolderIndex() {
public static function KraftausdruckFolderIndex()
{

$fileClasses = ClassInfo::subclassesFor(File::class);

if (count($fileClasses)) {
if (count($fileClasses) && ClassInfo::hasTable('File')) {
$blockingFolders = Folder::get()->filter(['ShowInSearch' => 0]);
$blockingFoldersArr = [];
foreach ($blockingFolders as $bf) {
Expand All @@ -38,7 +41,7 @@ public static function KraftausdruckFolderIndex() {
}
}
}
if(count($subBlockingFoldersArr)) {
if (count($subBlockingFoldersArr)) {
$blockingFolders = $blockingFolders->exclude(['ID' => $subBlockingFoldersArr]);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/RobotsFoldersExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function updateDisallowedUrls(&$urls)
if (Robots::config()->disallow_unsearchable) {
$blockingFolders = Folder::get()->filter(['ShowInSearch' => 0]);
foreach ($blockingFolders as $folder) {
$urls[] = '/assets/'. $folder->getFilename();
$urls[] = '/assets/' . $folder->getFilename();
}
}
}
Expand Down

0 comments on commit 892da10

Please sign in to comment.