-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code refactor, add languages support, update README
- Loading branch information
Showing
8 changed files
with
53 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
# API plugin to [Question2Answer](http://question2answer.org/) | ||
# API plugin to [Question2Answer](https://question2answer.org/) | ||
|
||
Simple API plugin to serving data from Q2A script in JSON. | ||
Creates simple API and serve some data as JSON. | ||
|
||
Tested on **Q2A version >= 1.7.0 and PHP >= 7.0**. Code style adjusted to Q2A style. | ||
|
||
## Installation | ||
|
||
Clone or download this repository to *qa-plugin* directory in your Q2A. | ||
Clone or download this repository or selected [release](https://github.com/awaluk/q2a-api/releases) to *qa-plugin* directory in your Q2A. | ||
|
||
## Available functions | ||
|
||
- **/api/favorites** - getting favorites for logged user: users, questions, tags and categories | ||
|
||
|
||
--- | ||
## Available endpoints | ||
|
||
**Important notice about code!** | ||
This code don't respect PHP PSR-2 standard, because Question2Answer unfortunately too don't respect this. Also, I couldn't design classes and functions in my own way, because most of them impose Question2Answer script. | ||
- **/api/favorites** - get favorites data for logged user: users, questions, tags and categories | ||
```json | ||
{ | ||
"questions": ["2", "1"], | ||
"users": ["Example username"], | ||
"tags": ["Example tag 1", "Example tag 2"], | ||
"categories": ["Example category"] | ||
} | ||
``` |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return [ | ||
'user_not_logged' => 'User not logged' | ||
]; |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return [ | ||
'user_not_logged' => 'Użytkownik niezalogowany' | ||
]; |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
{ | ||
"name": "Q2A API", | ||
"uri": "https://github.com/awaluk/q2a-api", | ||
"description": "Simple API serving data from Q2A in JSON", | ||
"version": "0.1", | ||
"date": "2017-09-01", | ||
"description": "Creates simple API and serve some data as JSON", | ||
"version": "0.1.0", | ||
"date": "2020-08-29", | ||
"author": "Arkadiusz Waluk", | ||
"author_uri": "http://waluk.pl", | ||
"author_uri": "https://waluk.pl", | ||
"license": "MIT", | ||
"min_q2a": "1.5", | ||
"update_uri": "https://raw.githubusercontent.com/awaluk/q2a-api/master/metadata.json" | ||
"update_uri": "https://raw.githubusercontent.com/awaluk/q2a-api/master/metadata.json", | ||
"min_q2a": "1.7", | ||
"min_php": "7.0" | ||
} |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
<?php | ||
/** | ||
* Q2A API - plugin to Question2Answer | ||
* @author Arkadiusz Waluk <arkadiusz@waluk.pl> | ||
*/ | ||
|
||
/* | ||
Plugin Name: Q2A API | ||
Plugin URI: https://github.com/awaluk/q2a-api | ||
Plugin Description: Simple API serving data from Q2A in JSON | ||
Plugin Version: 0.1 | ||
Plugin Date: 2017-09-01 | ||
Plugin Author: Arkadiusz Waluk | ||
Plugin Author URI: https://waluk.pl | ||
Plugin License: MIT | ||
Plugin Minimum Question2Answer Version: 1.5 | ||
Plugin Update Check URI: https://raw.githubusercontent.com/awaluk/q2a-api/master/metadata.json | ||
Plugin Name: Q2A API | ||
Plugin URI: https://github.com/awaluk/q2a-api | ||
Plugin Description: Creates simple API and serve some data as JSON | ||
Plugin Version: 0.1.0 | ||
Plugin Date: 2020-08-29 | ||
Plugin Author: Arkadiusz Waluk | ||
Plugin Author URI: https://waluk.pl | ||
Plugin License: MIT | ||
Plugin Update Check URI: https://raw.githubusercontent.com/awaluk/q2a-api/master/metadata.json | ||
Plugin Minimum Question2Answer Version: 1.7 | ||
Plugin Minimum PHP Version: 7.0 | ||
*/ | ||
|
||
if (!defined('QA_VERSION')) { | ||
header('Location: ../../'); | ||
exit; | ||
header('Location: ../../'); | ||
exit(); | ||
} | ||
|
||
qa_register_plugin_module('page', 'api-favorites.php', 'api_favorites', 'API user favorites'); | ||
define('API_URL', 'api/'); | ||
qa_register_plugin_module('page', 'src/api-favorites.php', 'api_favorites', 'API favorites'); | ||
qa_register_plugin_phrases('lang/*.php', 'q2a_api'); | ||
|
||
require_once 'api-functions.php'; | ||
require_once 'src/api-functions.php'; |
This file contains 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 characters
This file contains 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 characters