Skip to content

Commit

Permalink
Fix markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
dvlpp committed Sep 22, 2017
1 parent 5f6c33f commit 3db9f4c
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 62 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Sharp
# Sharp

*A Laravel CMS for developers who hate CMS*

Expand All @@ -12,7 +12,7 @@ Well, I think I can try to be clearer: in many of my web projects there's a lot

---

##Installation
## Installation

- Through composer, add `"dvlpp/sharp": "~1.0"` in your require section, and run `composer update`.
- Next add `'Dvlpp\Sharp\SharpServiceProvider'` in your app.php providers section.
Expand All @@ -24,7 +24,7 @@ OK, you're good to go. One final note: after an composer update, always re-run t

---

##Full documentation
## Full documentation

[Here's the doc index](docs/index.md).

Expand Down
8 changes: 4 additions & 4 deletions docs/authentication.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Authentication and rights management
# Authentication and rights management

Sharp shall not be responsible of the auth or access rights management of a particular application: implementation is your choice.

Expand All @@ -7,7 +7,7 @@ Sharp shall not be responsible of the auth or access rights management of a part
3. [Rights management](#rights)


##<a name="config"></a> 1. Config
## <a name="config"></a> 1. Config

To enable authentication, we simply indicate a Auth service class in the application config (`site.php`):

Expand All @@ -21,7 +21,7 @@ return [
```


##<a name="auth"></a> 2. Auth service
## <a name="auth"></a> 2. Auth service

Then, we have to write this `Quincy\Sharp\SharpAuthentication` class, making it implements `Dvlpp\Sharp\Auth\SharpAuth`:

Expand Down Expand Up @@ -75,7 +75,7 @@ Once the class is written, we can test it by hitting any Sharp page, and we get
Notice also that a logout link appears in Sharp's header.


##<a name="rights"></a> 3. Rights management
## <a name="rights"></a> 3. Rights management

Question is now: how to authorize specific users for specific actions? Suppose we want to set our rights this way:

Expand Down
18 changes: 10 additions & 8 deletions docs/auto_updater.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Sharp Eloquent auto-updater
# Sharp Eloquent auto-updater

If you read the [Entity forms](docs/entity_form.md) chapter, you probably noticed that the update or create code to write in the entity repository can be tricky, or at least a bit long, especially when posting big entities with lists and tags and stuff.

Expand All @@ -12,7 +12,7 @@ The good news is that if you are using Eloquent for your models, you can probabl



##<a name="magic"></a> 1. The auto-updater Trait magic
## <a name="magic"></a> 1. The auto-updater Trait magic

Here's how the giraffe repository is managing `update()` and `create()` methods:

Expand Down Expand Up @@ -46,7 +46,7 @@ First two arguments are useful to review the configuration and find out the type
And... that's mostly it: this function does all the boring job. But it will sometimes need some help, as explained below.


##<a name="file"></a> 2. The file upload case
## <a name="file"></a> 2. The file upload case

File uploads needs a little extra work: if you use the SharpEloquentRepositoryUpdaterTrait on a repository that manage an entity which contains file uploads, you need to implement a special interface: `SharpEloquentRepositoryUpdaterWithUploads`. This interface will require 3 methods:

Expand Down Expand Up @@ -81,7 +81,7 @@ Finally, the last method, `deleteFileUpload()`, is called when a file is deleted
Of course, it's easy to manage this in a project Trait, and code it only once, based on your file upload storage implementation choices.


##<a name="list"></a> 3. List special config
## <a name="list"></a> 3. List special config

Lists offers two optional config parameters:

Expand All @@ -105,15 +105,15 @@ So, as an example:
```


##<a name="tags"></a> 4. Pivot tags special config
## <a name="tags"></a> 4. Pivot tags special config

Very similarly to lists, pivot tags have also optional config parameters dedicated to the auto-updater:

- `order_attribute`, like list
- `create_attribute` is more specific: for pivot tags fields which authorize on-the-fly creation (with `addable` parameter), this must be filled with the model attribute name which will be updated with the string tag.


##<a name="specific"></a> 5. Wait, this particular attribute is specific
## <a name="specific"></a> 5. Wait, this particular attribute is specific

Of course, you will sometimes need extra code for some attributes, or you will maybe want to override the default behavior. Well, you want hooks, and there's one per attribute.

Expand All @@ -123,7 +123,8 @@ The rule is simple: if you have in your repo a method called `update[AttributeNa
function updateNameAttribute($instance, $value)
{
// Do anything with the value
return false;}
return false;
}
```

If the method returns false, the auto updater will skip to the next posted value. If true, the auto update process will continue just as planned.
Expand All @@ -140,7 +141,8 @@ function createPhotosListItem($instance)
return new Photo([
"animal_id" => $instance->id,
"animal_type" => 'Quincy\Sharp\Giraffe\Giraffe'
]);}
]);
}
```

In fact, if we let Sharp doing this alone, in this case, only `animal_id` would be valued, because there's no way it could guess the `animal_type` specific thing (for [polymorphic relation](http://laravel.com/docs/eloquent#polymorphic-relations)).
Expand Down
12 changes: 6 additions & 6 deletions docs/commands.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Commands
# Commands

Let's say that our zoo administrator wants to execute some specific actions like export a CSV file of a giraffe list, or quickly update an attribute right from the list view, or even have a online page preview before publishing content. Well, that why there's commands in Sharp.

Expand All @@ -8,7 +8,7 @@ Let's say that our zoo administrator wants to execute some specific actions like
3. [Download command](#download)
4. [Auth](#auth)

##<a name="config"></a> 1. Command config
## <a name="config"></a> 1. Command config

It always start with some config:

Expand Down Expand Up @@ -60,7 +60,7 @@ Next, there's 3 possible types: "download", "reload" and "view". They are explai
A new caret appeared at the end of each row, with a submenu containing all commands. The same is true on the list itself, thanks to the "Export" list command, for which the caret is in the blue list bar, on the right.


##<a name="reload"></a> 2. Reload command
## <a name="reload"></a> 2. Reload command

Our first entity command is called "birthday", and refers to a `Quincy\Sharp\Giraffe\BirthdayCommand` command handler. Well, let's create this class and let it implement `Dvlpp\Sharp\Commands\SharpEntityCommand`.

Expand Down Expand Up @@ -92,7 +92,7 @@ class BirthdayCommand implements SharpEntityCommand {
The `execute()` method is required, and accept the `$instanceId` (a giraffe id for us) as a parameter. All we have to do is the increment the age, and return nothing, in the command "reload" case.


##<a name="view"></a> 3. View command
## <a name="view"></a> 3. View command

The "preview" entity command we described above is a little bit different: in a "view" type, meaning that Sharp must load a view (specified in the config) with the command data in a new window. Here's the command handler `execute()` method possible code:

Expand All @@ -107,7 +107,7 @@ function execute($instanceId)
Sharp will load the `sharp_previews/giraffe` view with a `$giraffe` parameter, and open it in a new browser window / tab.


##<a name="download"></a> 4. Download command
## <a name="download"></a> 4. Download command

To demonstrate the download command, let's take a list command this time, named "export". The goal is to create a CSV file of the displayed giraffe list and send it to the user.

Expand Down Expand Up @@ -163,7 +163,7 @@ As you can see, the execute method accept a SharpEntitiesListParams parameter, v

As expected, when the command is called, the generated csv file is downloaded.

##<a name="auth"></a> 4. Auth
## <a name="auth"></a> 4. Auth

Commands require by default an "update" auth on the entity. To change that, simply add a `auth` attribute on the command config:

Expand Down
14 changes: 7 additions & 7 deletions docs/concepts.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#Sharp's concepts
# Sharp's concepts

Don't worry, there's not much.

## Entities
An *entity* is a business object that Sharp has to manipulate. Let's say, for example, a Client, or a Giraffe (in a zoo case).

##Categories
## Categories
A *category* is just a place to store entities. So giraffes could be stored in a *Ruminant* category, or maybe in some *Africa* zoo department.

##Sublist
## Sublist
A *sublist* is used to group entities. This isn't required, be could be useful in some transversal cases. Take a theatre, for example: we have to manage some *event* or *show* entities, but we would likely group them in *seasons*. Well, in this case, season is a sublist, which can apply to several entities (events, but also tickets prices, and maybe blog posts, ...).

##Repository
## Repository
This one is probably more obvious. Sharp needs *repositories* to work with, which are the abstraction layer between Sharp and the data. Those repos must implements specific interfaces.

##Validator
## Validator
*Validators* are simple descriptive classes used while... validating data.

##Field
## Field
A *field* is obviously a web composant used to let a user enter data. There are many field types in Sharp, but we'll get to this later.

##Command
## Command
A *command* is a project specific action executed on an entity or on an entities list.
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Sharp's config file(s)
# Sharp's config file(s)

Sharp development is divided in two parts: the coding (by extending / implementing Sharp's classes or interfaces), and the data description, done in config files. Sharp has two of them:

Expand Down
18 changes: 9 additions & 9 deletions docs/entities_list.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Entities list
# Entities list

1. [The entities list config](#config)
1. [Sorting](#sorting)
Expand All @@ -9,7 +9,7 @@
2. [Reordering](#reordering)
2. [Sublists](#sublists)

##<a name="config"></a> 1. The entities list config
## <a name="config"></a> 1. The entities list config

All that we need here is store under the `list_template` attribute in the config:

Expand Down Expand Up @@ -55,7 +55,7 @@ All that stuff will be covered in this chapter. Let's just be global here:

OK, let's see:

##<a name="sorting"></a> 2. Sorting
## <a name="sorting"></a> 2. Sorting

OK, let's work on the giraffe list; but first, we need some data to work with. After a [faker](https://github.com/fzaninotto/Faker)-based seed, we not have 50 animals:

Expand All @@ -80,7 +80,7 @@ function listAll(SharpEntitiesListParams $params)
Line by line, I first chose to eager load zookeeper (because I want to add its name on a column of the list, later). Then I make use of the SharpEntitiesListParams parameter, which contains (among other things) the sorted column and sorted direction. And I can now use he column sorting!


##<a name="renderers"></a> 3. Columns renderers
## <a name="renderers"></a> 3. Columns renderers

I'm not happy with the height column: data is expressed in cm, and I could like to have it in ft / inch. We can use a column renderer for that, which allows to format the displayed data.

Expand Down Expand Up @@ -149,7 +149,7 @@ They can be used like this:
```


##<a name="activation"></a> 4. Activation / Deactivation
## <a name="activation"></a> 4. Activation / Deactivation

Notice the blue or outlined star at the end of each row? This is the active state indicator (we talk about it in the [Config](config.md) page). The idea is to provide a basic way to declare an instance online or offline. We defined it this way in the config:

Expand Down Expand Up @@ -178,7 +178,7 @@ function deactivate($id)
We can now clic on the activate / deactivate star buttons.


##<a name="pagination"></a> 5. Pagination
## <a name="pagination"></a> 5. Pagination

In many cases we'll need pagination in entities lists. It's very easy to tackle with Sharp. First, as usual, the config:

Expand Down Expand Up @@ -222,7 +222,7 @@ The fact is giraffe are now paginated:

![](img/listview-giraffe-pagination.png)

##<a name="search"></a> 6. Search
## <a name="search"></a> 6. Search

The idea is to add a quick search functionality. So, in the config, we activate the search:

Expand Down Expand Up @@ -271,7 +271,7 @@ One again, the philosophy is that we can implement this search in many ways, dep
Notice we iterate over a `$params->getSearchTerms()` collection first, to search for all words. Notice also that we don't add the necessary '%' characters around `$term`: it's a default. To override this, simply provide prefix and suffix to the method: `$params->getSearchTerms($prefix, $suffix)`.


##<a name="reordering"></a> 7. Reordering
## <a name="reordering"></a> 7. Reordering

OK, I think we are going to need another entity to work with. We have Giraffe and Zookeeper (this one will be used in the next paragraph). To keep it simple, let's say our zoo areas are divided in *zones*, like savanna, mountains, and so on. We just have to create an entity config for those zones, a model, and a repo. Then insert some data, and:

Expand Down Expand Up @@ -314,7 +314,7 @@ And now, we can clic on the reorder button, drag and drop zones and validate to
Notice that I choose for this tutorial to manage order with an integer attribute, which is a brutal way to do it. But Sharp doesn't need you to do it this way: depending on the project or the entity, you can use integer, or some previous / next pointer, or anything else.


##<a name="sublists"></a> 8. Sublists
## <a name="sublists"></a> 8. Sublists

Like I said before, sublists are a transversal way to group entities. I gave a good season and theatre example in the [concepts](concepts.md) page, but in our case let's say we want to group giraffes (and other animals) by zookeepers.

Expand Down
Loading

0 comments on commit 3db9f4c

Please sign in to comment.