Skip to content

Commit

Permalink
Allowing by env variable to hide users status message on homepage.
Browse files Browse the repository at this point in the history
  • Loading branch information
vluzrmos committed Aug 2, 2015
1 parent 6e77f52 commit 671a294
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
9 changes: 8 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

# Your Team Slack Token
# (REQUIRED) Your Team Slack Token
SLACK_TOKEN=YOUR-SLACK-TOKEN-WITH-ADMIN-PRIVILEGIES

# (OPTIONAL) Indicates if should show the slack status message with users ative/total registered.
SLACK_STATUS_ENABLED=true

#####################################################################################
## Language Detector Configurations ##
## see https://github.com/vluzrmos/laravel-language-detector ##
#####################################################################################

#Indicates whenever should autodetect the language (it could be removed)
LANG_DETECTOR_AUTODETECT=true

#The driver to use, default is browser
LANG_DETECTOR_DRIVER="browser"

#The segment to use in uri or subdomain driver, default 0 (it could be removed)
LANG_DETECTOR_SEGMENT=0

#A comma-separated list of available languages on application
LANG_DETECTOR_LANGUAGES="en,pt_BR"

#To aliase the language use the notation ":", "=", ":=" or "=>" to separate the alias and its value.
# LANG_DETECTOR_LANGUAGES="en, en-us:en, pt-br:pt_BR"
5 changes: 4 additions & 1 deletion app/Http/Controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ public function __construct(Cache $cache, SlackStatusService $slack)
public function getIndex()
{
$data = [
'totals' => $this->slack->getUsersStatus(),
'team' => $this->slack->getTeamInfo(),
];

if (env('SLACK_STATUS_ENABLED', true)) {
$data['totals'] = $this->slack->getUsersStatus();
}

return view('slack.index', $data);
}

Expand Down
12 changes: 11 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Change the <code>SLACK_TOKEN</code> to the token of your user on slack team, wit

## Run

## Queue
Start the queue listener:

```bash
Expand All @@ -44,14 +45,23 @@ php artisan queue:listen --timeout=240 1>> /dev/null 2>&1 &
@reboot php /path/to/that/project/artisan queue:listen --timeout=240 1>> /dev/null 2>&1
```

### Scheduled Tasks (Optional)

You may also need to add that command to your cronjob, that will update the users status on every minute:

```bash
* * * * * php /path/to/that/project/artisan schedule:run 1>> /dev/null 2>&1
```

That will make your queue run in background and ignoring error messages.


**Note:** If you do not want to use that feature, you just need to set the environment
variable `SLACK_STATUS_ENABLED` to `false` on your `.env` file, that will hide the message
about users active (online/total) of your team on the homepage:

SLACK_STATUS_ENABLED=false

### HTTP Server

Start the http server:

Expand Down
2 changes: 2 additions & 0 deletions resources/views/slack/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
{!! trans('slackin.join', ['team' => $team['name']]) !!}
</div>

@if(isset($totals, $totals['active'], $totals['total']))
<div id="status" >
{!! trans_choice('slackin.users_online', $totals['active'], $totals) !!}
</div>
@endif

<div id="form-invite" class="col-sm-6 col-sm-offset-3">
<div id="validation-message"></div>
Expand Down

0 comments on commit 671a294

Please sign in to comment.