├── .gitignore ├── controllers ├── agents │ ├── index.htm │ ├── config_import_export.yaml │ ├── preview.htm │ ├── config_form.yaml │ ├── import.htm │ ├── export.htm │ ├── config_list.yaml │ ├── _list_toolbar.htm │ ├── create.htm │ └── update.htm ├── humans │ ├── index.htm │ ├── _information.htm │ ├── config_relation.yaml │ ├── preview.htm │ ├── config_form.yaml │ ├── config_list.yaml │ ├── _list_toolbar.htm │ ├── create.htm │ └── update.htm ├── robots │ ├── index.htm │ ├── reorder.htm │ ├── _directives.htm │ ├── _relation_button_reorder.htm │ ├── config_reorder.yaml │ ├── config_relation.yaml │ ├── _reorder_toolbar.htm │ ├── config_form.yaml │ ├── config_list.yaml │ ├── _list_toolbar.htm │ ├── create.htm │ └── update.htm ├── Settings.php ├── Humans.php ├── Agents.php ├── Robots.php └── settings │ └── index.htm ├── models ├── child │ ├── fields.yaml │ └── columns.yaml ├── agentexport │ └── columns.yaml ├── agentimport │ └── columns.yaml ├── directive │ ├── columns.yaml │ └── fields.yaml ├── information │ ├── columns.yaml │ └── fields.yaml ├── robot │ ├── fields.yaml │ └── columns.yaml ├── agent │ ├── columns.yaml │ └── fields.yaml ├── human │ ├── fields.yaml │ └── columns.yaml ├── AgentExport.php ├── Agent.php ├── AgentImport.php ├── Information.php ├── Setting.php ├── setting │ └── fields.yaml ├── ParentModel.php ├── Child.php ├── Directive.php ├── Robot.php └── Human.php ├── composer.json ├── updates ├── create_robots_table.php ├── create_humans_table.php ├── create_agents_table.php ├── create_directives_table.php ├── create_information_table.php ├── refactor_settings_human_fields.php ├── add_new_line_column.php ├── update_txt_parent_ids_nullable.php ├── seed_agents_table.php ├── version.yaml ├── drop_timestamps.php ├── create_parents_table.php └── create_children_table.php ├── routes.php ├── phpunit.xml ├── .github └── workflows │ └── tests.yml ├── README.md ├── lang ├── tr │ └── lang.php ├── cs │ └── lang.php ├── pl │ └── lang.php ├── lv │ └── lang.php ├── zh-cn │ └── lang.php ├── en │ └── lang.php └── hi │ └── lang.php ├── tests └── PluginTest.php ├── Plugin.php └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.lock 3 | .phpunit.result.cache -------------------------------------------------------------------------------- /controllers/agents/index.htm: -------------------------------------------------------------------------------- 1 | 2 | = $this->listRender() ?> 3 | -------------------------------------------------------------------------------- /controllers/humans/index.htm: -------------------------------------------------------------------------------- 1 | 2 | = $this->listRender() ?> 3 | -------------------------------------------------------------------------------- /controllers/robots/index.htm: -------------------------------------------------------------------------------- 1 | 2 | = $this->listRender() ?> 3 | -------------------------------------------------------------------------------- /controllers/robots/reorder.htm: -------------------------------------------------------------------------------- 1 | = $this->reorderRender(); ?> 2 | -------------------------------------------------------------------------------- /controllers/humans/_information.htm: -------------------------------------------------------------------------------- 1 | 2 | = $this->relationRender('information') ?> 3 | -------------------------------------------------------------------------------- /controllers/robots/_directives.htm: -------------------------------------------------------------------------------- 1 | 2 | = $this->relationRender('directives') ?> 3 | -------------------------------------------------------------------------------- /models/child/fields.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Form Field Definitions 3 | # =================================== 4 | 5 | fields: 6 | id: 7 | label: ID 8 | disabled: true 9 | -------------------------------------------------------------------------------- /models/child/columns.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # List Column Definitions 3 | # =================================== 4 | 5 | columns: 6 | id: 7 | label: ID 8 | searchable: true 9 | -------------------------------------------------------------------------------- /controllers/robots/_relation_button_reorder.htm: -------------------------------------------------------------------------------- 1 | 4 | Reorder 5 | 6 | -------------------------------------------------------------------------------- /models/agentexport/columns.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Column Definitions 3 | # =================================== 4 | 5 | columns: 6 | name: mohsin.txt::lang.agent.name 7 | comment: mohsin.txt::lang.agent.comment 8 | -------------------------------------------------------------------------------- /models/agentimport/columns.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Column Definitions 3 | # =================================== 4 | 5 | columns: 6 | name: mohsin.txt::lang.agent.name 7 | comment: mohsin.txt::lang.agent.comment 8 | -------------------------------------------------------------------------------- /models/directive/columns.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # List Column Definitions 3 | # =================================== 4 | 5 | columns: 6 | field: 7 | label: Type 8 | 9 | value: 10 | label: Data 11 | -------------------------------------------------------------------------------- /models/information/columns.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # List Column Definitions 3 | # =================================== 4 | 5 | columns: 6 | field: 7 | label: Field 8 | searchable: true 9 | 10 | value: 11 | label: Value 12 | searchable: true 13 | -------------------------------------------------------------------------------- /models/robot/fields.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Form Field Definitions 3 | # =================================== 4 | 5 | fields: 6 | agent: 7 | label: User-Agent 8 | type: dropdown 9 | 10 | directives: 11 | label: Directives 12 | type: partial 13 | path: directives 14 | -------------------------------------------------------------------------------- /models/agent/columns.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # List Column Definitions 3 | # =================================== 4 | 5 | columns: 6 | name: 7 | label: mohsin.txt::lang.agent.name 8 | searchable: true 9 | 10 | comment: 11 | label: mohsin.txt::lang.agent.comment 12 | searchable: true 13 | -------------------------------------------------------------------------------- /models/human/fields.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Form Field Definitions 3 | # =================================== 4 | 5 | fields: 6 | attribution: 7 | label: Attribution 8 | type: dropdown 9 | 10 | information: 11 | label: Information 12 | type: partial 13 | path: information 14 | -------------------------------------------------------------------------------- /models/robot/columns.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # List Column Definitions 3 | # =================================== 4 | 5 | columns: 6 | key: 7 | label: Agent 8 | searchable: true 9 | 10 | directives_count: 11 | label: Number of Entries 12 | relation: directives_count 13 | relationCount: true 14 | -------------------------------------------------------------------------------- /models/human/columns.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # List Column Definitions 3 | # =================================== 4 | 5 | columns: 6 | key: 7 | label: Attribution 8 | searchable: true 9 | 10 | information_count: 11 | label: Number of Entries 12 | relation: information_count 13 | relationCount: true 14 | -------------------------------------------------------------------------------- /controllers/robots/config_reorder.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Reorder Behavior Config 3 | # =================================== 4 | 5 | # Reorder Title 6 | title: Reorder Directives 7 | 8 | # Attribute name 9 | nameFrom: data 10 | 11 | # Model Class name 12 | modelClass: Mohsin\Txt\Models\Directive 13 | 14 | # Toolbar widget configuration 15 | toolbar: 16 | buttons: reorder_toolbar 17 | -------------------------------------------------------------------------------- /models/AgentExport.php: -------------------------------------------------------------------------------- 1 | each(function ($agent) use ($columns) { 11 | $agent->addVisible($columns); 12 | }); 13 | return $agent->toArray(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /controllers/humans/config_relation.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Relation Behavior Config 3 | # =================================== 4 | 5 | information: 6 | label: Information 7 | deferredBinding: true 8 | manage: 9 | form: $/mohsin/txt/models/information/fields.yaml 10 | list: $/mohsin/txt/models/information/columns.yaml 11 | view: 12 | list: $/mohsin/txt/models/information/columns.yaml 13 | toolbarButtons: create|delete 14 | -------------------------------------------------------------------------------- /controllers/robots/config_relation.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Relation Behavior Config 3 | # =================================== 4 | 5 | directives: 6 | label: Directive 7 | deferredBinding: true 8 | manage: 9 | form: $/mohsin/txt/models/directive/fields.yaml 10 | list: $/mohsin/txt/models/directive/columns.yaml 11 | view: 12 | list: $/mohsin/txt/models/directive/columns.yaml 13 | toolbarButtons: create|delete|reorder 14 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mohsin/txt-plugin", 3 | "type": "october-plugin", 4 | "description": "Allows generating humans.txt and robots.txt with ease.", 5 | "homepage": "http://imoz.in", 6 | "keywords": ["octobercms", "humans","robots","txt", "attribution"], 7 | "authors": [ 8 | { 9 | "name": "Saifur Rahman Mohsin", 10 | "email": "mohsin92@me.com" 11 | } 12 | ], 13 | "require": { 14 | "composer/installers": "~1.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /models/agent/fields.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Form Field Definitions 3 | # =================================== 4 | 5 | fields: 6 | name: 7 | label: mohsin.txt::lang.agent.name 8 | commentAbove: mohsin.txt::lang.agent.name_comment 9 | placeholder: mohsin.txt::lang.agent.name_placeholder 10 | 11 | comment: 12 | label: mohsin.txt::lang.agent.comment 13 | commentAbove: mohsin.txt::lang.agent.comment_comment 14 | placeholder: mohsin.txt::lang.agent.comment_placeholder 15 | -------------------------------------------------------------------------------- /models/information/fields.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Form Field Definitions 3 | # =================================== 4 | 5 | fields: 6 | field: 7 | label: Field 8 | commentAbove: Any identifier (Designation, Twitter, Location, etc.) 9 | span: left 10 | 11 | value: 12 | label: Value 13 | commentAbove: The value of the identifier (Developer, India, etc.) 14 | span: right 15 | 16 | new_line: 17 | label: Add New Line? (To end a section) 18 | type: checkbox 19 | -------------------------------------------------------------------------------- /models/directive/fields.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Form Field Definitions 3 | # =================================== 4 | 5 | fields: 6 | type: 7 | label: Type 8 | commentAbove: The type of directive. 9 | type: dropdown 10 | span: left 11 | 12 | data: 13 | label: Data 14 | commentAbove: A string for comment, a relative URL for other types 15 | placeholder: "/private" 16 | span: right 17 | 18 | new_line: 19 | label: Add New Line? (To end a section) 20 | type: checkbox -------------------------------------------------------------------------------- /controllers/agents/config_import_export.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Import/Export Behavior Config 3 | # =================================== 4 | 5 | import: 6 | title: mohsin.txt::lang.agent.import_agent 7 | modelClass: Mohsin\Txt\Models\AgentImport 8 | list: $/mohsin/txt/models/agentimport/columns.yaml 9 | redirect: mohsin/txt/agents 10 | 11 | export: 12 | title: mohsin.txt::lang.agent.export_agent 13 | fileName: agents.csv 14 | modelClass: Mohsin\Txt\Models\AgentExport 15 | list: $/mohsin/txt/models/agentexport/columns.yaml 16 | redirect: mohsin/txt/agents 17 | -------------------------------------------------------------------------------- /updates/create_robots_table.php: -------------------------------------------------------------------------------- 1 | engine = 'InnoDB'; 12 | $table->increments('id'); 13 | $table->string('agent'); 14 | $table->timestamps(); 15 | }); 16 | } 17 | 18 | public function down() 19 | { 20 | Schema::dropIfExists('mohsin_txt_robots'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /updates/create_humans_table.php: -------------------------------------------------------------------------------- 1 | engine = 'InnoDB'; 12 | $table->increments('id'); 13 | $table->string('attribution'); 14 | $table->timestamps(); 15 | }); 16 | } 17 | 18 | public function down() 19 | { 20 | Schema::dropIfExists('mohsin_txt_humans'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /controllers/robots/_reorder_toolbar.htm: -------------------------------------------------------------------------------- 1 | 2 |
11 | Return to Edit Robot 14 | 15 |
16 |= e(trans('backend::lang.form.return_to_list')) ?>
18 | 19 | 20 | -------------------------------------------------------------------------------- /controllers/humans/preview.htm: -------------------------------------------------------------------------------- 1 | 2 |= e(trans('backend::lang.form.return_to_list')) ?>
18 | 19 | 20 | -------------------------------------------------------------------------------- /updates/create_agents_table.php: -------------------------------------------------------------------------------- 1 | engine = 'InnoDB'; 14 | $table->increments('id'); 15 | $table->string('name')->unique(); 16 | $table->string('comment')->nullable(); 17 | $table->timestamps(); 18 | }); 19 | } 20 | 21 | public function down() 22 | { 23 | Schema::dropIfExists('mohsin_txt_agents'); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /controllers/agents/config_form.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Form Behavior Config 3 | # =================================== 4 | 5 | # Record name 6 | name: Agent 7 | 8 | # Model Form Field configuration 9 | form: $/mohsin/txt/models/agent/fields.yaml 10 | 11 | # Model Class name 12 | modelClass: Mohsin\Txt\Models\Agent 13 | 14 | # Default redirect location 15 | defaultRedirect: mohsin/txt/agents 16 | 17 | # Create page 18 | create: 19 | title: backend::lang.form.create_title 20 | redirect: mohsin/txt/agents/update/:id 21 | redirectClose: mohsin/txt/agents 22 | 23 | # Update page 24 | update: 25 | title: backend::lang.form.update_title 26 | redirect: mohsin/txt/agents 27 | redirectClose: mohsin/txt/agents 28 | -------------------------------------------------------------------------------- /controllers/humans/config_form.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Form Behavior Config 3 | # =================================== 4 | 5 | # Record name 6 | name: Human 7 | 8 | # Model Form Field configuration 9 | form: $/mohsin/txt/models/human/fields.yaml 10 | 11 | # Model Class name 12 | modelClass: Mohsin\Txt\Models\Human 13 | 14 | # Default redirect location 15 | defaultRedirect: mohsin/txt/humans 16 | 17 | # Create page 18 | create: 19 | title: backend::lang.form.create_title 20 | redirect: mohsin/txt/humans/update/:id 21 | redirectClose: mohsin/txt/humans 22 | 23 | # Update page 24 | update: 25 | title: backend::lang.form.update_title 26 | redirect: mohsin/txt/humans 27 | redirectClose: mohsin/txt/humans 28 | -------------------------------------------------------------------------------- /controllers/robots/config_form.yaml: -------------------------------------------------------------------------------- 1 | # =================================== 2 | # Form Behavior Config 3 | # =================================== 4 | 5 | # Record name 6 | name: Robot 7 | 8 | # Model Form Field configuration 9 | form: $/mohsin/txt/models/robot/fields.yaml 10 | 11 | # Model Class name 12 | modelClass: Mohsin\Txt\Models\Robot 13 | 14 | # Default redirect location 15 | defaultRedirect: mohsin/txt/robots 16 | 17 | # Create page 18 | create: 19 | title: backend::lang.form.create_title 20 | redirect: mohsin/txt/robots/update/:id 21 | redirectClose: mohsin/txt/robots 22 | 23 | # Update page 24 | update: 25 | title: backend::lang.form.update_title 26 | redirect: mohsin/txt/robots 27 | redirectClose: mohsin/txt/robots 28 | -------------------------------------------------------------------------------- /routes.php: -------------------------------------------------------------------------------- 1 | generateTxt(), 200, array('Content-Type' => 'text/plain')); 13 | }); 14 | 15 | Route::get('humans.txt', function () { 16 | if (!Setting::get('use_humans') || !Human::first()) { 17 | return Redirect::to(Page::url(Setting::get('redirectpage'))); 18 | } 19 | return Response::make(Human::first()->generateTxt(), 200, array('Content-Type' => 'text/plain')); 20 | }); 21 | -------------------------------------------------------------------------------- /updates/create_directives_table.php: -------------------------------------------------------------------------------- 1 | engine = 'InnoDB'; 13 | $table->increments('id'); 14 | $table->integer('robot_id')->default(0); 15 | $table->integer('position')->default(0); 16 | $table->string('type'); 17 | $table->string('data'); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | public function down() 23 | { 24 | Schema::dropIfExists('mohsin_txt_directives'); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /updates/create_information_table.php: -------------------------------------------------------------------------------- 1 | engine = 'InnoDB'; 13 | $table->increments('id'); 14 | $table->integer('human_id')->default(0); 15 | $table->integer('position')->default(0); 16 | $table->string('field'); 17 | $table->string('value'); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | public function down() 23 | { 24 | Schema::dropIfExists('mohsin_txt_information'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /models/Agent.php: -------------------------------------------------------------------------------- 1 | 'required' 35 | ]; 36 | } 37 | -------------------------------------------------------------------------------- /models/AgentImport.php: -------------------------------------------------------------------------------- 1 | 'required' 13 | ]; 14 | 15 | public function importData($results, $sessionKey = null) 16 | { 17 | foreach ($results as $row => $data) { 18 | try { 19 | $agent = new Agent; 20 | $agent->fill($data); 21 | $agent->save(); 22 | 23 | $this->logCreated(); 24 | } 25 | catch (\Exception $ex) { 26 | $this->logError($row, $ex->getMessage()); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /updates/refactor_settings_human_fields.php: -------------------------------------------------------------------------------- 1 | $value) { 20 | $human_new_fields[$key] = array('human_field' => $value); 21 | } 22 | 23 | Setting::set('human_fields', $human_new_fields); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /updates/add_new_line_column.php: -------------------------------------------------------------------------------- 1 | boolean('new_line')->default(false); 12 | }); 13 | 14 | Schema::table('mohsin_txt_information', function ($table) { 15 | $table->boolean('new_line')->default(false); 16 | }); 17 | } 18 | 19 | public function down() 20 | { 21 | Schema::table('mohsin_txt_directives', function ($table) { 22 | $table->dropColumn('new_line'); 23 | }); 24 | 25 | Schema::table('mohsin_txt_information', function ($table) { 26 | $table->dropColumn('new_line'); 27 | }); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /updates/update_txt_parent_ids_nullable.php: -------------------------------------------------------------------------------- 1 | integer('robot_id')->nullable()->change(); 12 | }); 13 | 14 | Schema::table('mohsin_txt_information', function ($table) { 15 | $table->integer('human_id')->nullable()->change(); 16 | }); 17 | } 18 | 19 | public function down() 20 | { 21 | Schema::table('mohsin_txt_directives', function ($table) { 22 | $table->integer('robot_id')->nullable(false)->change(); 23 | }); 24 | 25 | Schema::table('mohsin_txt_information', function ($table) { 26 | $table->integer('human_id')->nullable(false)->change(); 27 | }); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /controllers/agents/import.htm: -------------------------------------------------------------------------------- 1 | 2 |= e(trans('backend::lang.form.return_to_list')) ?>
47 | 48 | 49 | -------------------------------------------------------------------------------- /controllers/humans/create.htm: -------------------------------------------------------------------------------- 1 | 2 |= e(trans('backend::lang.form.return_to_list')) ?>
47 | 48 | 49 | -------------------------------------------------------------------------------- /controllers/robots/create.htm: -------------------------------------------------------------------------------- 1 | 2 |= e(trans('backend::lang.form.return_to_list')) ?>
47 | 48 | 49 | -------------------------------------------------------------------------------- /tests/PluginTest.php: -------------------------------------------------------------------------------- 1 | 'Bingbot']); 15 | $this->assertDatabaseHas('mohsin_txt_parents', [ 16 | 'key' => 'Bingbot', 17 | 'is_robot' => 1 18 | ]); 19 | 20 | $robot->directives()->add(Directive::create([ 21 | 'field' => 'Disallow', 22 | 'value' => '/google' 23 | ])); 24 | $robot->directives()->add(Directive::create([ 25 | 'field' => 'Sitemap', 26 | 'value' => 'ms-sitemap.xml', 27 | 'new_line' => 1 28 | ])); 29 | 30 | $this->assertDatabaseHas('mohsin_txt_children', [ 31 | 'parent_id' => $robot->id, 32 | 'field' => 'Disallow', 33 | 'value' => '/google', 34 | 'new_line' => 0, 35 | 'is_robot' => 1 36 | ]); 37 | $this->assertDatabaseHas('mohsin_txt_children', [ 38 | 'parent_id' => $robot->id, 39 | 'field' => 'Sitemap', 40 | 'value' => 'ms-sitemap.xml', 41 | 'new_line' => 1, 42 | 'is_robot' => 1 43 | ]); 44 | 45 | // Test Humans Txt 46 | $team = Human::create(['key' => 'Team']); 47 | $this->assertDatabaseHas('mohsin_txt_parents', [ 48 | 'key' => 'Team', 49 | 'is_robot' => 0 50 | ]); 51 | 52 | $team->information()->add(Information::create([ 53 | 'field' => 'Developer', 54 | 'value' => 'Mohsin' 55 | ])); 56 | 57 | $this->assertDatabaseHas('mohsin_txt_children', [ 58 | 'parent_id' => $team->id, 59 | 'field' => 'Developer', 60 | 'value' => 'Mohsin', 61 | 'new_line' => 0, 62 | 'is_robot' => 0 63 | ]); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /controllers/settings/index.htm: -------------------------------------------------------------------------------- 1 | fatalError): ?> 2 | 3 | = Form::open(['class' => 'layout']) ?> 4 | 5 |= e(trans('system::lang.settings.return')) ?>
49 | 50 | -------------------------------------------------------------------------------- /controllers/agents/update.htm: -------------------------------------------------------------------------------- 1 | 2 |= e(trans('backend::lang.form.return_to_list')) ?>
55 | 56 | 57 | -------------------------------------------------------------------------------- /controllers/humans/update.htm: -------------------------------------------------------------------------------- 1 | 2 |= e(trans('backend::lang.form.return_to_list')) ?>
55 | 56 | 57 | -------------------------------------------------------------------------------- /controllers/robots/update.htm: -------------------------------------------------------------------------------- 1 | 2 |= e(trans('backend::lang.form.return_to_list')) ?>
55 | 56 | 57 | -------------------------------------------------------------------------------- /updates/create_parents_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->boolean('is_robot')->default(false); 19 | $table->string('key')->unique(); 20 | }); 21 | 22 | // Move all existing robots to the parent model. 23 | $robots = DB::table('mohsin_txt_robots')->get(); 24 | foreach ($robots as $robot) { 25 | $parent = new ParentModel; 26 | $parent->is_robot = true; 27 | $parent->key = $robot->agent; 28 | $parent->save(); 29 | } 30 | Schema::drop('mohsin_txt_robots'); 31 | 32 | // Move all existing humans to the parent model. 33 | $humans = DB::table('mohsin_txt_humans')->get(); 34 | foreach ($humans as $human) { 35 | $parent = new ParentModel; 36 | $parent->is_robot = false; 37 | $parent->key = $human->attribution; 38 | $parent->save(); 39 | } 40 | Schema::drop('mohsin_txt_humans'); 41 | } 42 | 43 | public function down() 44 | { 45 | // Recreate the robots table. 46 | Schema::create('mohsin_txt_robots', function ($table) { 47 | $table->engine = 'InnoDB'; 48 | $table->increments('id'); 49 | $table->string('agent'); 50 | }); 51 | 52 | // Move all existing robot txts out of the parent model. 53 | foreach (ParentModel::robots()->get() as $parent) { 54 | DB::table('mohsin_txt_robots')->insert([ 55 | 'agent' => $parent->key 56 | ]); 57 | } 58 | 59 | // Recreate the humans table. 60 | Schema::create('mohsin_txt_humans', function ($table) { 61 | $table->engine = 'InnoDB'; 62 | $table->increments('id'); 63 | $table->string('attribution'); 64 | }); 65 | 66 | // Move all existing human txts out of the parent model. 67 | foreach (ParentModel::humans()->get() as $parent) { 68 | DB::table('mohsin_txt_humans')->insert([ 69 | 'attribution' => $parent->key, 70 | ]); 71 | } 72 | 73 | Schema::drop('mohsin_txt_parents'); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /models/Directive.php: -------------------------------------------------------------------------------- 1 | 'Please select a directive type.', 22 | 'value.required' => 'Data cannot be empty.' 23 | ]; 24 | 25 | /** 26 | * @var array Relations 27 | */ 28 | public $belongsTo = [ 29 | 'robot' => [ 30 | \Mohsin\txt\Models\Robot::class, 31 | 'table' => 'mohsin_txt_parents' 32 | ] 33 | ]; 34 | 35 | /** 36 | * Override the boot method to limit this model to robot 37 | * txts in the parent model. 38 | */ 39 | protected static function boot() 40 | { 41 | static::addGlobalScope('directive', function ($builder) { 42 | $builder->where('is_robot', 1); 43 | }); 44 | parent::boot(); 45 | } 46 | 47 | /** 48 | * Overloads the type attribute to use the child equivalent. 49 | * 50 | * @return string 51 | */ 52 | public function getTypeAttribute() 53 | { 54 | return $this->field; 55 | } 56 | 57 | /** 58 | * Overloads the type attribute to use the child equivalent. 59 | * 60 | * @return string 61 | */ 62 | public function setTypeAttribute($value) 63 | { 64 | $this->field = $value; 65 | } 66 | 67 | /** 68 | * Overloads the data attribute to use the child equivalent. 69 | * 70 | * @return string 71 | */ 72 | public function getDataAttribute() 73 | { 74 | return $this->value; 75 | } 76 | 77 | /** 78 | * Overloads the data attribute to use the child equivalent. 79 | * 80 | * @return string 81 | */ 82 | public function setDataAttribute($value) 83 | { 84 | $this->value = $value; 85 | } 86 | 87 | /** 88 | * @var string|null $fieldName The Field name 89 | * @var string|null $keyValue The key value 90 | * @return array The available type options 91 | */ 92 | public function getTypeOptions($fieldName = null, $keyValue = null) 93 | { 94 | return [ 95 | 'Allow' => 'Allow', 96 | 'Disallow' => 'Disallow', 97 | 'Host' => 'Host', 98 | 'Sitemap' => 'Sitemap' 99 | ]; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /models/Robot.php: -------------------------------------------------------------------------------- 1 | 'The user agent cannot be empty.' 27 | ]; 28 | 29 | /** 30 | * @var array Relations 31 | */ 32 | public $hasMany = [ 33 | 'directives' => [ 34 | \Mohsin\Txt\Models\Directive::class, 35 | 'order' => 'position asc', 36 | 'key' => 'parent_id' 37 | ], 38 | 'directives_count' => [ 39 | \Mohsin\Txt\Models\Directive::class, 40 | 'count' => true, 41 | 'key' => 'parent_id' 42 | ] 43 | ]; 44 | 45 | /** 46 | * Override the boot method to limit this model to robot 47 | * txts in the parent model. 48 | */ 49 | protected static function boot() 50 | { 51 | static::addGlobalScope('robot', function ($builder) { 52 | $builder->where('is_robot', 1); 53 | }); 54 | parent::boot(); 55 | } 56 | 57 | /** 58 | * Overloads the agent attribute to use the parent equivalent. 59 | * 60 | * @return string 61 | */ 62 | public function getAgentAttribute() 63 | { 64 | return $this->key; 65 | } 66 | 67 | /** 68 | * Overloads the agent attribute to use the parent equivalent. 69 | * 70 | * @return string 71 | */ 72 | public function setAgentAttribute($value) 73 | { 74 | $this->key = $value; 75 | } 76 | 77 | /** 78 | * Returns associative array of available agents. 79 | * 80 | * @return array 81 | */ 82 | public function getAgentOptions($fieldName = null, $keyValue = null) 83 | { 84 | $isUpdateContext = Event::fire('robot.agent.getContext'); 85 | $removedValues = array_values($this->lists('key', 'id')); 86 | if ($isUpdateContext && isset(current($isUpdateContext)->agent)) { // Let the agent key of the update context exist. 87 | $keyToExclude = current($isUpdateContext)->agent; 88 | $removedValues = array_filter($removedValues, function ($value) use ($keyToExclude) { 89 | return $keyToExclude !== $value; 90 | }); 91 | } 92 | return Agent::whereNotIn('name', $removedValues)->lists('comment', 'name'); 93 | } 94 | 95 | /** 96 | * Returns generated text from the Robot model. 97 | * 98 | * @return string 99 | */ 100 | public function generateTxt() 101 | { 102 | $robots = ""; 103 | foreach (Robot::all() as $robot) { 104 | $robots .= 'User-agent: ' . $robot->agent . PHP_EOL; 105 | foreach ($robot->directives as $directive) { 106 | $robots .= $directive->type . ': ' . $directive->data . PHP_EOL; 107 | $robots .= $directive->new_line ? PHP_EOL : ''; 108 | } 109 | $robots .= PHP_EOL; 110 | } 111 | 112 | /* 113 | * Compatability with RainLab.Sitemap 114 | */ 115 | if (class_exists('\RainLab\Sitemap\Classes\DefinitionItem')) { 116 | $url = URL::to('/sitemap.xml'); 117 | $robots .= 'Sitemap: ' . $url; 118 | } 119 | 120 | return $robots; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /models/Human.php: -------------------------------------------------------------------------------- 1 | 'Attribution field cannot be empty.' 21 | ]; 22 | 23 | /** 24 | * @var array hasOne and other relations 25 | */ 26 | public $hasMany = [ 27 | 'information' => [ 28 | 'Mohsin\Txt\Models\Information', 29 | 'table' => 'mohsin_txt_children', 30 | 'key' => 'parent_id', 31 | 'order' => 'position asc' 32 | ], 33 | 'information_count' => [ 34 | 'Mohsin\Txt\Models\Information', 35 | 'table' => 'mohsin_txt_children', 36 | 'order' => 'position asc', 37 | 'key' => 'parent_id', 38 | 'count' => true 39 | ] 40 | ]; 41 | 42 | /** 43 | * Override the boot method to limit this model to robot 44 | * txts in the parent model. 45 | */ 46 | protected static function boot() 47 | { 48 | static::addGlobalScope('humans', function ($builder) { 49 | $builder->where('is_robot', 0); 50 | }); 51 | parent::boot(); 52 | } 53 | 54 | /** 55 | * Overloads the type attribute to use the parent equivalent. 56 | * 57 | * @return string 58 | */ 59 | public function getAttributionAttribute() 60 | { 61 | return $this->key; 62 | } 63 | 64 | /** 65 | * Overloads the attribution attribute to use the parent equivalent. 66 | * 67 | * @return string 68 | */ 69 | public function setAttributionAttribute($value) 70 | { 71 | $this->key = $value; 72 | } 73 | 74 | /** 75 | * Returns associative array of available attributions. 76 | * 77 | * @return array The available attribution options. 78 | */ 79 | public function getAttributionOptions($fieldName = null, $keyValue = null) 80 | { 81 | // Get all possible human attributes. 82 | $allHumanFields = Setting::get('human_fields'); 83 | $allHumanFields = array_column($allHumanFields, 'human_field'); 84 | 85 | // Remove used human attributes. 86 | $removedValues = array_values($this->lists('key', 'id')); 87 | 88 | // In the update context, let the human attribute that's being updated exist. 89 | $isUpdateContext = Event::fire('human.information.getContext'); 90 | if ($isUpdateContext && isset(current($isUpdateContext)->attribution)) { 91 | $keyToExclude = current($isUpdateContext)->attribution; 92 | if (($key = array_search($keyToExclude, $removedValues)) !== false) { 93 | unset($removedValues[$key]); 94 | } 95 | } 96 | $activeHumanFields = array_diff($allHumanFields, $removedValues); 97 | return array_combine($activeHumanFields, $activeHumanFields); 98 | } 99 | 100 | /** 101 | * Returns generated text from the Humans model. 102 | * 103 | * @return string 104 | */ 105 | public function generateTxt() 106 | { 107 | $humans = ''; 108 | foreach (Human::all() as $human) { 109 | if (count($human->information) > 0) { 110 | $humans .= '/* ' . $human->attribution . ' */' . PHP_EOL; 111 | foreach ($human->information as $information) { 112 | $humans .= $information->field . ': ' .$information->value . PHP_EOL; 113 | $humans .= $information->new_line ? PHP_EOL : ''; 114 | } 115 | $humans .= PHP_EOL; 116 | } 117 | } 118 | return $humans; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /updates/create_children_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->boolean('is_robot')->default(false); 19 | $table->integer('parent_id')->unsigned()->nullable()->index(); 20 | $table->integer('position')->default(0); 21 | $table->string('field'); 22 | $table->string('value'); 23 | $table->boolean('new_line')->default(false); 24 | }); 25 | 26 | // Move all existing directives to the child model. 27 | $directives = DB::table('mohsin_txt_directives')->get(); 28 | foreach ($directives as $directive) { 29 | $child = new Child; 30 | $child->is_robot = true; 31 | $child->parent_id = $directive->robot_id; 32 | $child->position = $directive->position; 33 | $child->field = $directive->type; 34 | $child->value = $directive->data; 35 | $child->new_line = $directive->new_line; 36 | $child->save(); 37 | } 38 | Schema::dropIfExists('mohsin_txt_directives'); 39 | 40 | // Move all existing information to the child model. 41 | $information = DB::table('mohsin_txt_information')->get(); 42 | foreach ($information as $information) { 43 | $child = new Child; 44 | $child->is_robot = false; 45 | $child->parent_id = $information->human_id; 46 | $child->position = $information->position; 47 | $child->field = $information->field; 48 | $child->value = $information->value; 49 | $child->new_line = $information->new_line; 50 | $child->save(); 51 | } 52 | Schema::dropIfExists('mohsin_txt_information'); 53 | } 54 | 55 | public function down() 56 | { 57 | // Recreate the directives table. 58 | Schema::create('mohsin_txt_directives', function ($table) { 59 | $table->engine = 'InnoDB'; 60 | $table->increments('id'); 61 | $table->integer('robot_id')->default(0)->nullable(); 62 | $table->integer('position')->default(0); 63 | $table->string('type'); 64 | $table->string('data'); 65 | $table->boolean('new_line')->default(false); 66 | }); 67 | 68 | // Move all existing directives txts out of the child model. 69 | foreach (Child::directives()->get() as $child) { 70 | DB::table('mohsin_txt_directives')->insert([ 71 | 'robot_id' => $child->parent_id, 72 | 'position' => $child->position, 73 | 'type' => $child->field, 74 | 'data' => $child->value, 75 | 'new_line' => $child->new_line 76 | ]); 77 | } 78 | 79 | // Recreate the information table. 80 | Schema::create('mohsin_txt_information', function ($table) { 81 | $table->engine = 'InnoDB'; 82 | $table->increments('id'); 83 | $table->integer('human_id')->default(0)->nullable(); 84 | $table->integer('position')->default(0); 85 | $table->string('field'); 86 | $table->string('value'); 87 | $table->boolean('new_line')->default(false); 88 | }); 89 | 90 | // Move all existing information txts out of the child model. 91 | foreach (Child::information()->get() as $child) { 92 | DB::table('mohsin_txt_information')->insert([ 93 | 'human_id' => $child->parent_id, 94 | 'position' => $child->position, 95 | 'field' => $child->field, 96 | 'value' => $child->value, 97 | 'new_line' => $child->new_line 98 | ]); 99 | } 100 | 101 | Schema::dropIfExists('mohsin_txt_children'); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /Plugin.php: -------------------------------------------------------------------------------- 1 | 'mohsin.txt::lang.plugin.name', 21 | 'description' => 'mohsin.txt::lang.plugin.description', 22 | 'author' => 'Saifur Rahman Mohsin', 23 | 'icon' => 'icon-map-marker', 24 | 'homepage' => 'https://github.com/SaifurRahmanMohsin/txt-plugin', 25 | ]; 26 | } 27 | 28 | /** 29 | * boot method, called right before the request route. 30 | * 31 | * @return void 32 | */ 33 | public function boot() 34 | { 35 | Event::listen('system.settings.extendItems', function ($settingsManager) { 36 | if (\Mohsin\Txt\Models\Setting::get('use_robots')) { 37 | $settingsManager->addSettingItems('Mohsin.txt', [ 38 | 'robots' => [ 39 | 'label' => 'mohsin.txt::lang.robots.label', 40 | 'description' => 'mohsin.txt::lang.robots.description', 41 | 'category' => 'mohsin.txt::lang.plugin.name', 42 | 'icon' => 'icon-android', 43 | 'order' => 601, 44 | 'permissions' => ['mohsin.txt.access_robots'], 45 | 'url' => Backend::url('mohsin/txt/robots') 46 | ], 47 | 'agents' => [ 48 | 'label' => 'mohsin.txt::lang.agent.plural', 49 | 'description' => 'mohsin.txt::lang.agent.description', 50 | 'category' => 'mohsin.txt::lang.plugin.name', 51 | 'icon' => 'icon-search', 52 | 'order' => 602, 53 | 'permissions' => ['mohsin.txt.access_agents'], 54 | 'url' => Backend::url('mohsin/txt/agents') 55 | ] 56 | ]); 57 | } 58 | 59 | if (\Mohsin\Txt\Models\Setting::get('use_humans')) { 60 | $settingsManager->addSettingItems('Mohsin.txt', [ 61 | 'humans' => [ 62 | 'label' => 'mohsin.txt::lang.humans.label', 63 | 'description' => 'mohsin.txt::lang.humans.description', 64 | 'category' => 'mohsin.txt::lang.plugin.name', 65 | 'icon' => 'icon-users', 66 | 'order' => 603, 67 | 'permissions' => ['mohsin.txt.access_humans'], 68 | 'url' => Backend::url('mohsin/txt/humans') 69 | ] 70 | ]); 71 | } 72 | }); 73 | } 74 | 75 | /** 76 | * Registers any back-end permissions used by this plugin. 77 | * 78 | * @return array 79 | */ 80 | public function registerPermissions() 81 | { 82 | return [ 83 | 'mohsin.txt.access_settings' => [ 84 | 'tab' => 'mohsin.txt::lang.plugin.name', 85 | 'label' => 'mohsin.txt::lang.permissions.access_settings' 86 | ], 87 | 'mohsin.txt.access_humans' => [ 88 | 'tab' => 'mohsin.txt::lang.plugin.name', 89 | 'label' => 'mohsin.txt::lang.permissions.access_humans' 90 | ], 91 | 'mohsin.txt.access_robots' => [ 92 | 'tab' => 'mohsin.txt::lang.plugin.name', 93 | 'label' => 'mohsin.txt::lang.permissions.access_robots' 94 | ], 95 | 'mohsin.txt.access_agents' => [ 96 | 'tab' => 'mohsin.txt::lang.plugin.name', 97 | 'label' => 'mohsin.txt::lang.permissions.access_agents' 98 | ] 99 | ]; 100 | } 101 | 102 | /** 103 | * Registers any settings used by this plugin. 104 | * 105 | * @return array 106 | */ 107 | public function registerSettings() 108 | { 109 | return [ 110 | 'settings' => [ 111 | 'label' => 'mohsin.txt::lang.settings.label', 112 | 'description' => 'mohsin.txt::lang.settings.description', 113 | 'category' => 'mohsin.txt::lang.plugin.name', 114 | 'icon' => 'icon-cog', 115 | 'url' => Backend::url('mohsin/txt/settings'), 116 | 'class' => 'Mohsin\Txt\Models\Setting', 117 | 'order' => 600, 118 | 'permissions' => ['mohsin.txt.access_settings'], 119 | 'keywords' => 'txt robots humans' 120 | ] 121 | ]; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 |