mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
Merge branch 'twitter' into dev
This commit is contained in:
commit
fe387cbe3c
@ -46,6 +46,7 @@
|
||||
//= require elasticsearch-browser/elasticsearch.angular
|
||||
//= require d3/d3
|
||||
//= require nvd3/build/nv.d3.js
|
||||
//= require twitter-fetcher
|
||||
//= require app
|
||||
//= require router
|
||||
//= require medium-editor/dist/js/medium-editor
|
||||
|
@ -10,16 +10,13 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
Application.Controllers.controller('HomeController', ['$scope', '$stateParams', 'Twitter', 'lastMembersPromise', 'lastProjectsPromise', 'upcomingEventsPromise', 'homeBlogpostPromise', 'twitterNamePromise',
|
||||
function ($scope, $stateParams, Twitter, lastMembersPromise, lastProjectsPromise, upcomingEventsPromise, homeBlogpostPromise, twitterNamePromise) {
|
||||
Application.Controllers.controller('HomeController', ['$scope', '$stateParams', 'lastMembersPromise', 'lastProjectsPromise', 'upcomingEventsPromise', 'homeBlogpostPromise', 'twitterNamePromise',
|
||||
function ($scope, $stateParams, lastMembersPromise, lastProjectsPromise, upcomingEventsPromise, homeBlogpostPromise, twitterNamePromise) {
|
||||
/* PUBLIC SCOPE */
|
||||
|
||||
// The last registered members who confirmed their addresses
|
||||
$scope.lastMembers = lastMembersPromise;
|
||||
|
||||
// The last tweets from the Fablab official twitter account
|
||||
$scope.lastTweets = [];
|
||||
|
||||
// The last projects published/documented on the plateform
|
||||
$scope.lastProjects = lastProjectsPromise;
|
||||
|
||||
@ -45,10 +42,6 @@ Application.Controllers.controller('HomeController', ['$scope', '$stateParams',
|
||||
* Kind of constructor: these actions will be realized first when the controller is loaded
|
||||
*/
|
||||
const initialize = function () {
|
||||
// we retrieve tweets from here instead of ui-router's promise because, if adblock stop the API request,
|
||||
// this prevent the whole home page to be blocked
|
||||
$scope.lastTweets = Twitter.query({ limit: 1 });
|
||||
|
||||
// if we recieve a token to reset the password as GET parameter, trigger the
|
||||
// changePassword modal from the parent controller
|
||||
if ($stateParams.reset_password_token) {
|
||||
|
32
app/assets/javascripts/directives/twitter.js.erb
Normal file
32
app/assets/javascripts/directives/twitter.js.erb
Normal file
@ -0,0 +1,32 @@
|
||||
/* global twitterFetcher */
|
||||
|
||||
/**
|
||||
* This directive will allow show latest tweet.
|
||||
* Usage: <twitter profile="{{twitterName}}"/>
|
||||
*/
|
||||
Application.Directives.directive('twitter', [ function () {
|
||||
return ({
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
profile: '@'
|
||||
},
|
||||
templateUrl: '<%= asset_path "shared/_twitter.html" %>',
|
||||
link ($scope, element, attributes) {
|
||||
var configProfile = {
|
||||
'profile': { 'screenName': $scope.profile },
|
||||
'domId': 'twitter',
|
||||
'maxTweets': 1,
|
||||
'enableLinks': true,
|
||||
'showUser': false,
|
||||
'showTime': true,
|
||||
'showImages': false,
|
||||
'showRetweet': true,
|
||||
'showInteraction': false,
|
||||
'lang': Fablab.locale
|
||||
};
|
||||
if ($scope.profile) {
|
||||
twitterFetcher.fetch(configProfile);
|
||||
}
|
||||
}
|
||||
});
|
||||
}]);
|
@ -1,5 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
Application.Services.factory('Twitter', ['$resource', function ($resource) {
|
||||
return $resource('/api/feeds/twitter_timelines');
|
||||
}]);
|
@ -419,3 +419,19 @@
|
||||
.slider-nav__item--current {
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
|
||||
// Twitter
|
||||
#twitter {
|
||||
ul {
|
||||
margin: 0px 15px;
|
||||
padding-left: 0;
|
||||
li {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.timePosted {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
@ -20,26 +20,7 @@
|
||||
|
||||
|
||||
<div class="col-lg-4 m-t-lg">
|
||||
|
||||
<section class="widget panel b-a m-t-sm" ng-if="lastTweets.length > 0">
|
||||
<div class="panel-heading b-b small">
|
||||
<div class="pull-right text-xs align">
|
||||
<a href="https://twitter.com/{{ twitterName }}" ng-show="twitterName" target="_blank">{{ 'app.public.home.follow_us' | translate }}
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x text-yellow"></i>
|
||||
<i class="fa fa-twitter fa-stack-1x fa-inverse text-white"></i>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<h2 translate>{{ 'app.public.home.latest_tweets' }}</h2>
|
||||
</div>
|
||||
|
||||
<ul class="widget-content list-group list-group-lg no-bg auto">
|
||||
<li ng-repeat="tweet in lastTweets" class="text-sm list-group-item no-b clearfix" ng-bind-html="tweet.text">
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</section>
|
||||
<twitter profile="{{twitterName}}" ng-show="twitterName"/>
|
||||
|
||||
<section class="widget panel b-a" >
|
||||
<div class="panel-heading small b-b">
|
||||
|
14
app/assets/templates/shared/_twitter.html.erb
Normal file
14
app/assets/templates/shared/_twitter.html.erb
Normal file
@ -0,0 +1,14 @@
|
||||
<section class="widget panel b-a m-t-sm">
|
||||
<div class="panel-heading b-b small">
|
||||
<div class="pull-right text-xs align">
|
||||
<a href="https://twitter.com/{{ profile }}" target="_blank">{{ 'app.public.home.follow_us' | translate }}
|
||||
<span class="fa-stack fa-lg">
|
||||
<i class="fa fa-circle fa-stack-2x text-yellow"></i>
|
||||
<i class="fa fa-twitter fa-stack-1x fa-inverse text-white"></i>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<h2 translate>{{ 'app.public.home.latest_tweets' }}</h2>
|
||||
</div>
|
||||
<div id="twitter" class="widget-content no-bg auto"></div>
|
||||
</section>
|
@ -1,23 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# API Controller to wrap social networks public feeds
|
||||
class API::FeedsController < API::ApiController
|
||||
|
||||
respond_to :json
|
||||
|
||||
def twitter_timelines
|
||||
limit = if params
|
||||
params[:limit]
|
||||
else
|
||||
3
|
||||
end
|
||||
from_account = Setting.find_by(name: 'twitter_name').try(:value) || ENV['TWITTER_NAME']
|
||||
begin
|
||||
@tweet_news = Feed.twitter.user_timeline(from_account, count: limit)
|
||||
rescue Twitter::Error::BadRequest => e
|
||||
STDERR.puts "[WARNING] Unable to retrieve the twitter feed, please check your ENV configuration. Details: #{e.message}"
|
||||
render status: :no_content
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -1,10 +0,0 @@
|
||||
class Feed
|
||||
mattr_accessor :twitter do
|
||||
Twitter::REST::Client.new do |config|
|
||||
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
|
||||
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
|
||||
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
|
||||
config.access_token_secret = ENV['TWITTER_ACCESS_TOKEN_SECRET']
|
||||
end
|
||||
end
|
||||
end
|
@ -54,12 +54,8 @@ RECAPTCHA_SECRET_KEY: ''
|
||||
# Projects comments
|
||||
DISQUS_SHORTNAME:
|
||||
|
||||
# Twitter sharing & last tweet on home page
|
||||
# Twitter sharing
|
||||
TWITTER_NAME: 'FablabGrenoble'
|
||||
TWITTER_CONSUMER_KEY: ''
|
||||
TWITTER_CONSUMER_SECRET: ''
|
||||
TWITTER_ACCESS_TOKEN: ''
|
||||
TWITTER_ACCESS_TOKEN_SECRET: ''
|
||||
|
||||
# Facebook sharing
|
||||
FACEBOOK_APP_ID: ''
|
||||
@ -102,4 +98,3 @@ MAX_IMPORT_SIZE: '5242880'
|
||||
MAX_IMAGE_SIZE: '10485760'
|
||||
# 20971520 = 20 megabytes
|
||||
MAX_CAO_SIZE: '20971520'
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
Feed.twitter = Twitter::REST::Client.new do |config|
|
||||
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
|
||||
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
|
||||
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
|
||||
config.access_token_secret = ENV['TWITTER_ACCESS_TOKEN_SECRET']
|
||||
end
|
@ -72,7 +72,6 @@ Rails.application.routes.draw do
|
||||
|
||||
# for homepage
|
||||
get '/last_subscribed/:last' => 'members#last_subscribed'
|
||||
get '/feeds/twitter_timelines' => 'feeds#twitter_timelines'
|
||||
|
||||
get 'pricing' => 'pricing#index'
|
||||
put 'pricing' => 'pricing#update'
|
||||
|
@ -167,15 +167,8 @@ See https://help.disqus.com/customer/portal/articles/466208-what-s-a-shortname-
|
||||
|
||||
TWITTER_NAME
|
||||
|
||||
Identifier of the Twitter account, from witch the last tweet will be fetched and displayed on the home page.
|
||||
This value can be graphically overridden during the application's lifecycle in Admin/Customization/Home page/Twitter Feed.
|
||||
Identifier of the Twitter account for Twitter share project, event or training
|
||||
It will also be used for [Twitter Card analytics](https://dev.twitter.com/cards/analytics).
|
||||
<a name="TWITTER_CONSUMER_KEY"></a><a name="TWITTER_CONSUMER_SECRET"></a><a name="TWITTER_ACCESS_TOKEN"></a><a name="TWITTER_ACCESS_TOKEN_SECRET"></a>
|
||||
|
||||
TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_ACCESS_TOKEN & TWITTER_ACCESS_TOKEN_SECRET
|
||||
|
||||
Keys and secrets to access the twitter API.
|
||||
Retrieve them from https://apps.twitter.co.
|
||||
<a name="FACEBOOK_APP_ID"></a>
|
||||
|
||||
FACEBOOK_APP_ID
|
||||
|
@ -72,6 +72,7 @@
|
||||
"ngUpload": "0.5",
|
||||
"nvd3": "1.8",
|
||||
"summernote": "0.7.3",
|
||||
"twitter-fetcher": "^18.0.2",
|
||||
"ui-select": "0.19",
|
||||
"underscore": "1.7"
|
||||
}
|
||||
|
@ -40,10 +40,6 @@ RECAPTCHA_SECRET_KEY=
|
||||
DISQUS_SHORTNAME=
|
||||
|
||||
TWITTER_NAME=FablabGrenoble
|
||||
TWITTER_CONSUMER_KEY=
|
||||
TWITTER_CONSUMER_SECRET=
|
||||
TWITTER_ACCESS_TOKEN=
|
||||
TWITTER_ACCESS_TOKEN_SECRET=
|
||||
|
||||
FACEBOOK_APP_ID=
|
||||
|
||||
|
@ -212,8 +212,8 @@ configure_env_file()
|
||||
doc=$(\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/doc/environment.md)
|
||||
variables=(STRIPE_API_KEY STRIPE_PUBLISHABLE_KEY STRIPE_CURRENCY INVOICE_PREFIX FABLAB_WITHOUT_PLANS FABLAB_WITHOUT_SPACES FABLAB_WITHOUT_ONLINE_PAYMENT FABLAB_WITHOUT_INVOICES \
|
||||
PHONE_REQUIRED USER_CONFIRMATION_NEEDED_TO_SIGN_IN EVENTS_IN_CALENDAR SLOT_DURATION DEFAULT_MAIL_FROM DELIVERY_METHOD DEFAULT_HOST DEFAULT_PROTOCOL SMTP_ADDRESS SMTP_PORT SMTP_USER_NAME SMTP_PASSWORD SMTP_AUTHENTICATION \
|
||||
SMTP_ENABLE_STARTTLS_AUTO SMTP_OPENSSL_VERIFY_MODE SMTP_TLS GA_ID RECAPTCHA_SITE_KEY RECAPTCHA_SECRET_KEY DISQUS_SHORTNAME TWITTER_NAME TWITTER_CONSUMER_KEY TWITTER_CONSUMER_SECRET \
|
||||
TWITTER_ACCESS_TOKEN TWITTER_ACCESS_TOKEN_SECRET FACEBOOK_APP_ID LOG_LEVEL ALLOWED_EXTENSIONS ALLOWED_MIME_TYPES MAX_IMAGE_SIZE MAX_CAO_SIZE MAX_IMPORT_SIZE DISK_SPACE_MB_ALERT \
|
||||
SMTP_ENABLE_STARTTLS_AUTO SMTP_OPENSSL_VERIFY_MODE SMTP_TLS GA_ID RECAPTCHA_SITE_KEY RECAPTCHA_SECRET_KEY DISQUS_SHORTNAME TWITTER_NAME \
|
||||
FACEBOOK_APP_ID LOG_LEVEL ALLOWED_EXTENSIONS ALLOWED_MIME_TYPES MAX_IMAGE_SIZE MAX_CAO_SIZE MAX_IMPORT_SIZE DISK_SPACE_MB_ALERT \
|
||||
SUPERADMIN_EMAIL APP_LOCALE RAILS_LOCALE MOMENT_LOCALE SUMMERNOTE_LOCALE ANGULAR_LOCALE MESSAGEFORMAT_LOCALE FULLCALENDAR_LOCALE ELASTICSEARCH_LANGUAGE_ANALYZER TIME_ZONE \
|
||||
WEEK_STARTING_DAY D3_DATE_FORMAT UIB_DATE_FORMAT EXCEL_DATE_FORMAT OPENLAB_APP_ID OPENLAB_APP_SECRET OPENLAB_DEFAULT)
|
||||
for variable in "${variables[@]}"; do
|
||||
@ -331,4 +331,3 @@ setup()
|
||||
}
|
||||
|
||||
setup "$@"
|
||||
|
||||
|
@ -1498,6 +1498,11 @@ tslib@^1.9.0:
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
|
||||
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
|
||||
|
||||
twitter-fetcher@^18.0.2:
|
||||
version "18.0.2"
|
||||
resolved "https://registry.yarnpkg.com/twitter-fetcher/-/twitter-fetcher-18.0.2.tgz#47aeff8f3ccbec54443d7f5a5e845ed5279c0b5f"
|
||||
integrity sha1-R67/jzzL7FREPX9aXoRe1SecC18=
|
||||
|
||||
type-check@~0.3.2:
|
||||
version "0.3.2"
|
||||
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72"
|
||||
|
Loading…
x
Reference in New Issue
Block a user