Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .craftplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pluginName":"Like","pluginDescription":"A simple plugin to connect to Like's API.","pluginVersion":"1.0.0","pluginAuthorName":"Benjamin David","pluginVendorName":"dukt","pluginAuthorUrl":"https://github.com/benjamindavid","pluginAuthorGithub":"dukt","codeComments":"","pluginComponents":["controllers","models","records","services","settings","variables"],"consolecommandName":"","controllerName":"","cpsectionName":"","elementName":"","fieldName":"","modelName":"","purchasableName":"","recordName":"","serviceName":"","taskName":"","utilityName":"","widgetName":"","apiVersion":"api_version_3_0"}
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; top-most EditorConfig file
root = true

; Unix-style newlines
[*]
indent_style = space
indent_size = 2
end_of_line = LF
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.php]
indent_style = space
indent_size = 4
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# CRAFT ENVIRONMENT
.env.php
.env.sh
.env

# COMPOSER
/vendor

# BUILD FILES
/bower_components/*
/node_modules/*
/build/*
/yarn-error.log

# MISC FILES
.cache
.DS_Store
.idea
.project
.settings
*.esproj
*.sublime-workspace
*.sublime-project
*.tmproj
*.tmproject
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
config.codekit3
prepros-6.config
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Like Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 3.0.0 - 2022-05-28
### Changed
- Upgrade for craft 4

## 2.0.2 - 2022-03-20
### Fixed
- Merge changes

## 2.0.1 - 2022-03-20
### Fixed
- Ensure we are PSR-4 compliant

## 1.0.0 - 2018-07-27
### Added
- Initial release
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2018 Benjamin David

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
105 changes: 103 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,103 @@
craft-like
==========
# Like plugin for Craft CMS 3.x

A simple plugin to connect to Like's API.

![Screenshot](resources/img/plugin-logo.png)

## Requirements

This plugin requires Craft CMS 3.0.0-beta.23 or later.

## Installation

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

cd /path/to/project

2. Then tell Composer to load the plugin:

composer require dukt/like

3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Like.

## Templating

### Like button

{% if currentUser %}
{% if craft.like.isLike(element.id) %}
<a class="btn btn-default" href="/like/remove/{{element.id}}"><span class="glyphicon glyphicon-star"></span> Unlike</a>
{% else %}
<a class="btn btn-primary" href="/like/add/{{element.id}}"><span class="glyphicon glyphicon-star"></span> Like</a>
{% endif %}
{% else %}
<a class="btn disabled btn-primary" href="#">Like</a>
{% endif %}


### List likes for an element

{% set likes = craft.like.getLikes(element.id) %}

{% if likes|length > 0 %}

{% for like in likes %}
<a href="#">
{% if like.user.photoUrl %}
<img src="{{like.user.photoUrl}}" width="34" class="img-rounded" data-toggle="tooltip" data-original-title="{{like.user.email}}" />
{% else %}
<img src="http://placehold.it/34x34" data-toggle="tooltip" class="img-rounded" data-original-title="{{like.user.email}}">
{% endif %}
</a>
{% endfor %}

{% endif %}


### Your Likes

Entries and asset that you like.

Entries:

{% set entries = craft.like.getUserLikes('Entry') %}

{% if entries %}
<ul>
{% for entry in entries %}
<li>{{entry.title}}</li>
{% endfor %}
</ul>
{% else %}
<p>You haven't liked any entry yet.</p>
{% endif %}

Assets:

{% set assets = craft.like.getUserLikes('Asset') %}

{% if assets %}
<div class="row">
{% for asset in assets %}
<div class="col-md-4">
<img class="thumbnail img-responsive" src="{{asset.url({width:200, height: 140})}}" />
</div>
{% endfor %}
</div>
{% else %}
<p>You haven't liked any asset yet.</p>
{% endif %}


## API


### LikeVariable

- isLike($elementId)
- getLikes($elementId = null)
- getUserLikes($elementType = null, $userId = null)

Brought to you by [Benjamin David](https://github.com/benjamindavid)
7 changes: 7 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Updating our plugin to Craft CMS 4

Run a docker container, and then update as [per the instructions](https://github.com/craftcms/rector)

```
docker run -it --rm -v "$PWD":/app craftcms/php-fpm:8.1-dev /bin/ash
```
55 changes: 55 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "dukt/like",
"description": "Like plugin for Craft CMS",
"type": "craft-plugin",
"version": "3.0.0",
"keywords": [
"craft",
"cms",
"craftcms",
"craft-plugin",
"like"
],
"support": {
"docs": "https://github.com/dukt/like/blob/master/README.md",
"issues": "https://github.com/dukt/like/issues"
},
"license": "MIT",
"authors": [
{
"name": "Benjamin David",
"homepage": "https://github.com/benjamindavid"
}
],
"require": {
"craftcms/cms": "^4.0.0-alpha.1",
"php": "^8.0.2"
},
"autoload": {
"psr-4": {
"dukt\\like\\": "src/"
}
},
"extra": {
"name": "Like",
"handle": "like",
"hasCpSettings": true,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/dukt/like/master/CHANGELOG.md",
"components": {
"likeService": "dukt\\like\\services\\LikeService"
},
"class": "dukt\\like\\Like"
},
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true,
"craftcms/plugin-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"require-dev": {
"craftcms/rector": "dev-main"
}
}
Loading