Skip to content

Commit

Permalink
0.2.0
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Jun 14, 2017
1 parent 43d2b4a commit 2f774d1
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 440 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/daita/mood/badges/quality-score.png?b=master&)](https://scrutinizer-ci.com/g/daita/mood/?branch=master)

**Share your mood.**
**Your mood over the clouds.**

![](https://raw.githubusercontent.com/daita/mood/master/screenshots/0.1.0.png)
![](https://raw.githubusercontent.com/daita/mood/master/screenshots/0.2.0.png)


Mood will allow your cloud-users to socially share their mood. It will add an header to the Activity App.
Expand All @@ -15,8 +15,6 @@ This app will need:
- [Activity](https://github.com/nextcloud/activity) (from the app store)


**Mood is PRE-ALPHA. This project is mostly here to test Circles' API.**
**Mood is beta. This project is mostly here to test Circles' API.**

### Credits

App Icon by [Madebyoliver](http://www.flaticon.com/authors/madebyoliver) under Creative Commons BY 3.0
19 changes: 11 additions & 8 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>mood</id>
<name>mood</name>
<summary>mood</summary>
<description>mood</description>
<version>0.1.2</version>
<summary>Your mood over the clouds</summary>
<description>mood is a small app using **Circles** and **Activity** to broadcast your current mood in a social way.

Create your circles and federate them for a better visibility.
</description>
<version>0.2.0</version>
<licence>agpl</licence>
<author>Maxence Lange</author>
<documentation>
<admin>https://github.com/nextcloud-gmbh/mood/wiki</admin>
<admin>https://github.com/daita/mood/wiki</admin>
</documentation>
<category>social</category>
<website>https://github.com/nextcloud-gmbh/mood</website>
<bugs>https://github.com/nextcloud-gmbh/mood/issues</bugs>
<repository type="git">https://github.com/nextcloud-gmbh/mood.git</repository>
<!--<screenshot>https://raw.githubusercontent.com/nextcloud-gmbh/circles/master/screenshots/circlespng</screenshot>-->
<website>https://github.com/daita/mood</website>
<bugs>https://github.com/daita/mood/issues</bugs>
<repository type="git">https://github.com/daita/mood.git</repository>
<screenshot>https://raw.githubusercontent.com/daita/mood/master/screenshots/0.2.0.png</screenshot>-->
<dependencies>
<nextcloud min-version="12" max-version="13"/>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion img/mood.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions img/mood_black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/Activity/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getPriority() {
* @since 11.0.0
*/
public function getIcon() {
return $this->url->getAbsoluteURL($this->url->imagePath('mood', 'mood.svg'));
return $this->url->getAbsoluteURL($this->url->imagePath('mood', 'mood_black.svg'));
}

/**
Expand Down
59 changes: 20 additions & 39 deletions lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
namespace OCA\Mood\Activity;

use OCA\Circles\Api\v1\Circles;
use OCA\Circles\Model\FederatedLink;
use OCA\Circles\Model\SharingFrame;
use OCA\Mood\Service\MiscService;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
Expand All @@ -15,9 +13,6 @@

class Provider implements IProvider {

/** @var MiscService */
protected $miscService;

/** @var IL10N */
protected $l10n;

Expand All @@ -27,15 +22,13 @@ class Provider implements IProvider {
/** @var IManager */
protected $activityManager;

public function __construct(
IURLGenerator $url, IManager $activityManager, IL10N $l10n, MiscService $miscService
) {
public function __construct(IURLGenerator $url, IManager $activityManager, IL10N $l10n) {
$this->url = $url;
$this->activityManager = $activityManager;
$this->l10n = $l10n;
$this->miscService = $miscService;
}


/**
* @param string $lang
* @param IEvent $event
Expand All @@ -58,7 +51,7 @@ public function parse($lang, IEvent $event, IEvent $previousEvent = null) {
}

$event->setIcon(
$this->url->getAbsoluteURL($this->url->imagePath('mood', 'mood.svg'))
$this->url->getAbsoluteURL($this->url->imagePath('mood', 'mood_black.svg'))
);

$frame = SharingFrame::fromJSON($params['share']);
Expand Down Expand Up @@ -101,38 +94,23 @@ private function parseActivityHeader(IEvent &$event, SharingFrame $frame) {
&& $frame->getCloudId() === null
) {

$event->setParsedSubject(
$this->l10n->t(
'You shared a mood with %1$s', ['circle1, circle2']
)
)
->setRichSubject(
$this->l10n->t(
'You shared a mood with {circles}'
),
['circles' => $this->generateCircleParameter($frame)]
$event->setRichSubject(
$this->l10n->t('You shared a mood with {circles}'),
['circles' => $this->generateCircleParameter($frame)]

);
);

} else {

$author = $this->generateUserParameter($frame);
$event->setParsedSubject(
$event->setRichSubject(
$this->l10n->t(
'%1$s shared a mood with %2$s', [
$author['name'],
'circle1, circle2'
]
)
)
->setRichSubject(
$this->l10n->t(
'{author} shared a mood with {circles}'
), [
'author' => $author,
'circles' => $this->generateCircleParameter($frame)
]
);
'{author} shared a mood with {circles}'
), [
'author' => $author,
'circles' => $this->generateCircleParameter($frame)
]
);
}
}

Expand Down Expand Up @@ -168,15 +146,18 @@ private function generateCircleParameter(SharingFrame $frame) {
* @return array
*/
private function generateUserParameter(SharingFrame $frame) {
$host = '';
if ($frame->getCloudId() !== null) {
$host = '@' . $frame->getCloudId();
$name = $frame->getAuthor() . '@' . $frame->getCloudId();
} else {
$name = \OC::$server->getUserManager()
->get($frame->getAuthor())
->getDisplayName();
}

return [
'type' => 'user',
'id' => $frame->getAuthor(),
'name' => $frame->getAuthor() . $host
'name' => $name
];
}
}
104 changes: 14 additions & 90 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@

namespace OCA\Mood\AppInfo;

use \OCA\Mood\Controller\MoodController;
use OCA\Mood\Controller\MoodController;
use OCA\Mood\Controller\ToolsController;
use \OCA\Mood\Service\ConfigService;

use OCA\Mood\Service\HttpService;
use \OCA\Mood\Service\MiscService;
use OCA\Mood\Service\MoodService;
use OCP\AppFramework\App;
use OCP\Util;

Expand All @@ -51,38 +47,9 @@ public function __construct(array $params = array()) {
$container = $this->getContainer();
$this->appName = $container->query('AppName');

/**
* Services
*/
$container->registerService(
'MiscService', function($c) {
return new MiscService($c->query('Logger'), $c->query('AppName'));
}
);


$container->registerService(
'ConfigService', function($c) {
return new ConfigService(
$c->query('AppName'), $c->query('CoreConfig'), $c->query('UserId'),
$c->query('MiscService')
);
}
);

$container->registerService(
'MoodService', function($c) {
return new MoodService(
$c->query('ActivityManager'), $c->query('HttpService'), $c->query('MiscService')
);
}
);

$container->registerService(
'HttpService', function($c) {
return new HttpService(
$c->query('MiscService')
);
return new HttpService();
}
);

Expand All @@ -91,21 +58,15 @@ public function __construct(array $params = array()) {
*/
$container->registerService(
'MoodController', function($c) {
return new MoodController(
$c->query('AppName'), $c->query('Request'), $c->query('UserId'), $c->query('L10N'),
$c->query('MoodService'),
$c->query('MiscService')
);
return new MoodController($c->query('AppName'), $c->query('Request'));
}
);


$container->registerService(
'ToolsController', function($c) {
return new ToolsController(
$c->query('AppName'), $c->query('Request'), $c->query('UserId'), $c->query('L10N'),
$c->query('HttpService'),
$c->query('MiscService')
$c->query('AppName'), $c->query('Request'), $c->query('HttpService')
);
}
);
Expand All @@ -119,71 +80,34 @@ public function __construct(array $params = array()) {
}
);

/**
* Core
*/
$container->registerService(
'Logger', function($c) {
return $c->query('ServerContainer')
->getLogger();
}
);
$container->registerService(
'CoreConfig', function($c) {
return $c->query('ServerContainer')
->getConfig();
}
);

$container->registerService(
'UserId', function($c) {
$user = $c->query('ServerContainer')
->getUserSession()
->getUser();

return is_null($user) ? '' : $user->getUID();
}
);


$container->registerService(
'ActivityManager', function($c) {
return $c->query('ServerContainer')
->getActivityManager();
}
);


$container->registerService(
'UserManager', function($c) {
return $c->query('ServerContainer')
->getUserManager();
}
);

}


public function registerToActivity() {
if (!\OCP\App::isEnabled('circles')) {
$this->getContainer()
->query('MiscService')
->log("mood needs circles");
\OC::$server->getLogger()
->log(2, 'mood needs circles');

return;
}

\OC::$server->getEventDispatcher()
->addListener(
'OCA\Activity::loadAdditionalScripts', function() {
\OCP\Util::addScript('circles', 'circles.v1');
\OCP\Util::addScript('mood', 'mood');
\OCP\Util::addScript('mood', 'mood.app');
\OCP\Util::addScript('mood', 'mood.app.elements');
\OCP\Util::addScript('mood', 'mood.app.actions');
\OCP\Util::addScript('mood', 'mood.app.navigation');

\OCP\Util::addStyle('mood', 'navigate');
Util::addScript('circles', 'circles.v1');
Util::addScript('mood', 'mood');
Util::addScript('mood', 'mood.app');
Util::addScript('mood', 'mood.app.elements');
Util::addScript('mood', 'mood.app.actions');
Util::addScript('mood', 'mood.app.navigation');

Util::addStyle('mood', 'navigate');
}
);
}
Expand Down
Loading

0 comments on commit 2f774d1

Please sign in to comment.