Last active
March 2, 2021 23:19
-
-
Save joshxduncan/6ee4161c1c2ca3100b2c0e40a4ee53d2 to your computer and use it in GitHub Desktop.
Revisions
-
joshxduncan revised this gist
Mar 2, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -77,7 +77,7 @@ private function getValidProperties() } // Belongs to a post or page class Schema(SchemaType, SchemaTypePropertyRepository) { // Array of Property objects $properties = []; -
joshxduncan revised this gist
Mar 2, 2021 . 1 changed file with 3 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -79,21 +79,19 @@ private function getValidProperties() // Belongs to a post or page class Schema(SchemaType) { // Array of Property objects $properties = []; } // Can be a value for a SchemaProperty or a standalone Schema object // Has one or more SchemaProperties class SchemaType() { $validProperties = [ 'image' ]; $requiredProperties = [ ]; } // Belongs to a SchemaType (e.g. Person > jobTitle) -
joshxduncan revised this gist
Mar 2, 2021 . 1 changed file with 35 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,18 +66,42 @@ public function addProperty(SchemaTypeProperty $property) ] ] class SchemaPropertyManager() { private function getValidProperties() { $parentTypes = getParentProperties(); $ownTypes = getOwnProperties(); return $this->validProperties = array_merge($parentTypes, $ownTypes); } } // Belongs to a post or page class Schema(SchemaType) { } // Can be a value for a SchemaProperty or a standalone Schema object // Has one or more SchemaProperties class SchemaType (SchemaPropertyManager) { $validProperties = [ 'image' ]; $requiredProperties = [ ]; // Array of Property objects $properties = []; } // Belongs to a SchemaType (e.g. Person > jobTitle) // Has a value of SchemaType or a DataType (e.g. funder: Organization) class SchemaProperty () { $type = 'DataType'; $schemaType = 'jobTitle'; $expectedTypes = [ 'Properties' => [ 'DefinedTerm' @@ -91,17 +115,15 @@ class SchemaProperty { "SchemaType" => "Text" "data" => [] ]; private function getExpectedTypes() { $this->db->getExpectedPropertyType($propertyName); } } // Belongs to a SchemaProperty class SchemaDataType() { $value; } -
joshxduncan revised this gist
Mar 2, 2021 . 1 changed file with 42 additions and 80 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,25 +45,11 @@ public function addProperty(SchemaTypeProperty $property) 1. User: Selects the Person schema type 2. Software: shows new "schema form" with required properties -> Get required properties $requiredProperties = $form->propertyRepository->getRequiredProperties(); // Add the required property fields to the form as a default foreach ($requiredProperties as $property) { $form->addPropertyField($property); } 3. Software: allows user to add additional *valid* properties -> Get valid properties @@ -77,69 +63,45 @@ public function addPropertyField($property) Person [ 'properties' => [ 'URL' => 'example.com', ] ] class SchemaProperty { $type = 'DataType'; $schemaType = 'jobTitle'; $validProperties = [ 'image' ] $requiredProperties = [ ]; $expectedTypes = [ 'Properties' => [ 'DefinedTerm' ], 'DataTypes' => [ 'Text' ] ]; $value = [ "SchemaType" => "Text" "data" => [] ]; private function getValidProperties() { $parentTypes = getParentProperties(); $ownTypes = getOwnProperties(); return $this->validProperties = array_merge($parentTypes, $ownTypes); } private function getExpectedTypes() { $this->db->getExpectedPropertyType($propertyName); } } -
joshxduncan revised this gist
Mar 2, 2021 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -103,6 +103,25 @@ public function addPropertyField($property) // The problem with that strategy is that the accepted use of Quantity types is a string value, not a JSON "property" // declaration used for other "Things" e.g. "Person" Distance Duration Energy Mass These "DataTypes" can be converted to "JSON property" Thing SchemaTypes in the future if a "value" field is declared in the spec. That would involve a script that moves the text value stored for the corresponding property into a JSON object. e.g.: // Our current use "duration": "2014-12-21/P30D" would be changed to: "duration": { @type: "Duration", @value: "2014-12-21/P30D", description: "The duration of the Schema" }, The spec suggests that SchemaTypes can be used as Values for Properties in the form of a string but that breaks the spec and these Quantity Values will instead be grouped under DataTypes -
joshxduncan revised this gist
Mar 2, 2021 . 1 changed file with 22 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -89,21 +89,38 @@ public function addPropertyField($property) ] ] SchemaType // It appears that the SchemaTypes with the parent Thing > Intangible > Quantity should be used as // atomic DataTypes (no properties, just a Text value) in the Schema docs: https://schema.org/duration // However, this doesn\'t follow the rest of the spec, as several other developers have pointed out // with no response from the core team // https://github.com/schemaorg/schemaorg/issues/936 // https://github.com/schemaorg/schemaorg/issues/551 // https://github.com/schemaorg/schemaorg/issues/187 // We will treat Quantity Scheme subtypes as DataTypes in our software for that reason, in anticipation // of the spec being corrected // The other option is to use our own syntax, by introducing a "@value" or "value" property for these Quanity types. // The problem with that strategy is that the accepted use of Quantity types is a string value, not a JSON "property" // declaration used for other "Things" e.g. "Person" The spec suggests that SchemaTypes can be used as Values for Properties in the form of a string but that breaks the spec and these Quantity Values will instead be grouped under DataTypes SchemaType Hierarchy SchemaTypes are always a child of the Thing SchemaType and may inherit from one or more other parent SchemaTypes SchemaType Properties SchemaTypes have corresponding Properties and may implement all Properties defined by its parent(s) SchemaTypes Property Hierarchy Properties have values that are either a SchemaType or DataType Properties have other Properties DataType Data DataTypes always have a corresponding Value and may have optional Properties Value Data Values are atomic and do not have Properties e.g. "Number", "Text" private function getDataType($name){} private function getThing($name); -
joshxduncan created this gist
Mar 2, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,109 @@ <?php $properties = [ {property, 'name' => 'img'} {property, 'name' => 'address'} ]; $properties = [ ['img' => {property, 'name' => 'img'}], ['address' {property, 'name' => 'address'}] ]; /** * Get a propery by name * * @param string $name Name of the property to find * * @return ?SchemaTypeProperty */ public function getPropertyByName(string $name) : ? SchemaTypeProperty { return $this->properties[$name]; } /** * Adds a property to the schema type * * @param SchemaTypeProperty $property */ public function addProperty(SchemaTypeProperty $property) { // See if property already exists, if it exists add expected types to the property and push it to $this->properties array $propertytemp = $this->getPropertyByName($property->getName()); if (!is_null($propertytemp)) { $propertytemp->addExpectedTypes($property->getExpectedTypes()); } array_push($this->properties, (is_null($propertytemp)) ? $property : $propertytemp); } // User starts to build a new Schema 1. User: Selects the Person schema type 2. Software: shows new "schema form" with required properties -> Get required properties $requiredProperties = $form->propertyBuilder->getRequiredProperties(); // Add the required property fields to the form as a default foreach ($requiredProperties as $property) { $form->addProperty($property); } public function addPropertyField($property) { $name = $property->getName(); $validTypes = $property->getValidTypes(); $this->form->addPropertyField( 'type' => null, 'validProperties' => [], 'value' => [ 'properties' => [ ] ] ); } 3. Software: allows user to add additional *valid* properties -> Get valid properties $form->propertyBuilder->getValidProperties(); 4. User: Fills out required properties 5. User: Adds and fills out 2 additional optional properties 6. User: Saves form Person [ 'properties' => [ 'URL' => 'example.com', 'URL' => [ 'type' => 'URL' 'value' => 'example.com' 'properties' => [ 'correction'=> [], 'url' => ' ], ] ] ] SchemaType Hierarchy SchemaTypes are always a child of the Thing SchemaType and may inherit from one or more other parent SchemaTypes SchemaType Properties SchemaTypes have corresponding Properties and may implement all Properties defined by its parent(s) SchemaTypes Property Hierarchy Properties inherit either from either a SchemaType or DataType DataType Hierarchies DataTypes always have a corresponding Value and may have optional Properties Values Values are atomic and do not have Properties private function getDataType($name){} private function getThing($name);