diff --git a/CHANGELOG.md b/CHANGELOG.md index 29a9d3ce..e45a1298 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.1] - 2023-10-12 +### Changed +- Allow upload social media data to Clowder [#99](https://github.com/ncsa/standalone-smm-smile/issues/99) + +### Added +- More environment variable to control such as Twitter/Reddit Auth, Expiration date [#101](https://github.com/ncsa/standalone-smm-smile/issues/) + ## [0.3.0] - 2023-09-14 ### Fixed - Github action to auto generate docker container [#93](https://github.com/ncsa/standalone-smm-smile/issues/93) diff --git a/www/app.js b/www/app.js index 9adade63..502c2bae 100644 --- a/www/app.js +++ b/www/app.js @@ -26,9 +26,14 @@ var app = express(); */ smileHomePath = path.join(process.env.HOME, 'smile'); s3FolderName = process.env.USER || 'local'; -SINGLE_USER = 'true'; -CLOWDER_ON = process.env.CLOWDER_ON || 'false'; +SINGLE_USER = process.env.SINGLE_USER ? process.env.SINGLE_USER === 'true': true; +CLOWDER_ON = process.env.CLOWDER_ON ? process.env.CLOWDER_ON ==='true': false; +TWITTER_ON = process.env.TWITTER_ON ? process.env.TWITTER_ON ==='true': true; +REDDIT_ON = process.env.REDDIT_ON ? process.env.REDDIT_ON === 'true': true; +SHARE_EXPIRE_IN = process.env.SHARE_EXPIRE_IN ? process.env.SHARE_EXPIRE_IN : 1; CLOWDER_BASE_URL= process.env.CLOWDER_BASE_URL || "http://clowder.localhost/"; +BUCKET_NAME = process.env.BUCKET_NAME ? process.env.BUCKET_NAME: 'macroscope-smile'; +SMILE_GRAPHQL_URL = process.env.SMILE_GRAPHQL_URL ? process.env.SMILE_GRAPHQL_URL: "http://localhost:5050/graphql"; email = true; /** @@ -38,7 +43,6 @@ if (process.env.DOCKERIZED === 'true') { // determine credentials either from file or from environment variable REDIS_URL = process.env.REDIS_URL; RABBITMQ_URL = process.env.RABBITMQ_URL; - SMILE_GRAPHQL_URL = process.env.SMILE_GRAPHQL_URL; AWS_ACCESSKEY = process.env.AWS_ACCESSKEY; AWS_ACCESSKEYSECRET = process.env.AWS_ACCESSKEYSECRET; TWITTER_CONSUMER_KEY = process.env.TWITTER_CONSUMER_KEY; @@ -57,9 +61,6 @@ if (process.env.DOCKERIZED === 'true') { DROPBOX_CLIENT_SECRET = process.env.DROPBOX_CLIENT_SECRET; GOOGLE_CLIENT_ID = process.env.GOOGLE_CLIENT_ID; GOOGLE_CLIENT_SECRET = process.env.GOOGLE_CLIENT_SECRET; - BUCKET_NAME = process.env.BUCKET_NAME; - SINGLE_USER = process.env.SINGLE_USER; - CLOWDER_ON = process.env.CLOWDER_ON; if (process.env.EMAIL_HOST === "" || process.env.EMAIL_HOST === undefined || process.env.EMAIL_HOST === null || process.env.EMAIL_FROM_ADDRESS === "" || process.env.EMAIL_FROM_ADDRESS === undefined || process.env.EMAIL_FROM_ADDRESS === null) { @@ -71,7 +72,7 @@ if (process.env.DOCKERIZED === 'true') { batchHandler = new RabbitmqSender(); s3 = new S3Helper(true, AWS_ACCESSKEY, AWS_ACCESSKEYSECRET); - if (SINGLE_USER === 'true') { + if (SINGLE_USER) { global.checkIfLoggedIn = function (req, res, next) { req.user = {email: s3FolderName}; return next(); @@ -169,10 +170,6 @@ if (process.env.DOCKERIZED === 'true') { DROPBOX_CLIENT_SECRET = config.dropbox.client_secret; GOOGLE_CLIENT_ID = config.google.client_id; GOOGLE_CLIENT_SECRET = config.google.client_secret; - SMILE_GRAPHQL_URL = "http://localhost:5050/graphql"; - BUCKET_NAME = 'macroscope-smile'; - SINGLE_USER = 'true'; - CLOWDER_ON = 'false'; lambdaHandler = new LambdaHelper(AWS_ACCESSKEY, AWS_ACCESSKEYSECRET); batchHandler = new BatchHelper(AWS_ACCESSKEY, AWS_ACCESSKEYSECRET); @@ -240,8 +237,9 @@ analysesRoutesFiles.forEach(function (route, i) { introduction: formParam.introduction.join(" "), wiki: formParam.wiki, param: formParam, - SINGLE_USER: SINGLE_USER==='true', - CLOWDER_ON: CLOWDER_ON==='true', + SINGLE_USER: SINGLE_USER, + CLOWDER_ON: CLOWDER_ON, + SHARE_EXPIRE_IN: SHARE_EXPIRE_IN, user: req.user, enableEmail: email }); diff --git a/www/public/bootstrap/js/customized/view_helperFunc.js b/www/public/bootstrap/js/customized/view_helperFunc.js index ca62c3f4..71a40572 100644 --- a/www/public/bootstrap/js/customized/view_helperFunc.js +++ b/www/public/bootstrap/js/customized/view_helperFunc.js @@ -551,11 +551,10 @@ function submitHistory(currItem, folderURL){ // ADD TO CLOWDER MODAL $("#clowder-files-list").empty(); - if (data.title != 'Social Media'){ - clowderFileGen(data.download); - clowderFileMeta(); - $('.fileTags').tagsinput({ freeInput: true }); - } + clowderFileGen(data.download); + clowderFileMeta(); + $('.fileTags').tagsinput({ freeInput: true }); + if ('title' in data || 'ID' in data){ appendTitle(data.title, data.ID); diff --git a/www/routes/businessLogic/cite.js b/www/routes/businessLogic/cite.js index 629cb665..3425b684 100644 --- a/www/routes/businessLogic/cite.js +++ b/www/routes/businessLogic/cite.js @@ -5,7 +5,7 @@ router.get('/citation', function (req, res) { res.render('citation', { user: req.user, parent: '/', - SINGLE_USER:SINGLE_USER==='true' + SINGLE_USER:SINGLE_USER }); }); diff --git a/www/routes/businessLogic/history.js b/www/routes/businessLogic/history.js index 8f53e9d6..f3100c03 100644 --- a/www/routes/businessLogic/history.js +++ b/www/routes/businessLogic/history.js @@ -10,8 +10,9 @@ router.get('/history', checkIfLoggedIn, function (req, res, next) { res.render('history', { user: req.user, parent: '/', - SINGLE_USER: SINGLE_USER==='true', - CLOWDER_ON: CLOWDER_ON==='true', + SINGLE_USER: SINGLE_USER, + CLOWDER_ON: CLOWDER_ON, + SHARE_EXPIRE_IN: SHARE_EXPIRE_IN, enableEmail: email }); }); diff --git a/www/routes/index.js b/www/routes/index.js index 345eb769..db1643a1 100644 --- a/www/routes/index.js +++ b/www/routes/index.js @@ -49,7 +49,7 @@ router.get('/', function (req, res, next) { res.render('index', { user: req.user, pages: pages, - SINGLE_USER:SINGLE_USER==='true', + SINGLE_USER:SINGLE_USER, }); }); diff --git a/www/routes/search/query.js b/www/routes/search/query.js index 310348f9..27bd94df 100644 --- a/www/routes/search/query.js +++ b/www/routes/search/query.js @@ -22,7 +22,9 @@ router.get('/query', checkIfLoggedIn, function (req, res) { user: req.user, parent: '/', error: req.query.error, - SINGLE_USER: SINGLE_USER === 'true', + SINGLE_USER: SINGLE_USER, + CLOWDER_ON: CLOWDER_ON, + REDDIT_ON: REDDIT_ON, status: status, }); }) diff --git a/www/views/components/share.pug b/www/views/components/share.pug index 1d24c8c6..d4ff656e 100644 --- a/www/views/components/share.pug +++ b/www/views/components/share.pug @@ -7,7 +7,7 @@ div(id="share-modal" class="modal fade" role="dialog" data-backdrop="static" dat div(class="modal-body form") div(class="modal-message") div(class="form-group") - p Copy and share the link below. Please note that the link will expire in 7 days. + p Copy and share the link below. Please note that the link will expire in #{SHARE_EXPIRE_IN} day(s). div(class="form-group") div(class="col-md-10 col-md-10 col-xs-12") input(class="form-control" id="share-link", placeholder="Nothing to be shared yet") diff --git a/www/views/search/auth.pug b/www/views/search/auth.pug index 71a88250..ef6ec8e9 100644 --- a/www/views/search/auth.pug +++ b/www/views/search/auth.pug @@ -10,13 +10,25 @@ div(id="auth-panel") //img(src='bootstrap/img/logo/twitter-sm-logo.png', width="30px", height="30px") //| Twitter integration temporarily disabled div(class="twitterV2-auth", id="twitterV2-auth") - a(class="btn btn-primary btn-block auth-button", href="login/twitterV2") - img(src='bootstrap/img/logo/x-sm-logo.png', width="30px", height="30px") - | Authorize with your Twitter/X account - img(src="bootstrap/img/logo/checkbox.png", class="export-success", width="30px", style="display:none;") + if TWITTER_ON + a(class="btn btn-primary btn-block auth-button", href="login/twitterV2") + img(src='bootstrap/img/logo/x-sm-logo.png', width="30px", height="30px") + | Authorize with your Twitter/X account + img(src="bootstrap/img/logo/checkbox.png", class="export-success", width="30px", style="display:none;") + else + a(class="btn btn-primary btn-block auth-button", href="login/twitterV2" disabled) + img(src='bootstrap/img/logo/x-sm-logo.png', width="30px", height="30px") + | Twitter/X Temporarily Not Accessible + img(src="bootstrap/img/logo/checkbox.png", class="export-success", width="30px", style="display:none;") div(class="reddit-auth", id="reddit-auth") - a(class="btn btn-primary btn-block auth-button", href="login/reddit") - img(src='bootstrap/img/logo/reddit-sm-logo.png', width="30px",height="30px") - | Authorize with your Reddit account - img(src="bootstrap/img/logo/checkbox.png", class="export-success", width="30px", style="display:none;") + if REDDIT_ON + a(class="btn btn-primary btn-block auth-button", href="login/reddit") + img(src='bootstrap/img/logo/reddit-sm-logo.png', width="30px",height="30px") + | Authorize with your Reddit account + img(src="bootstrap/img/logo/checkbox.png", class="export-success", width="30px", style="display:none;") + else + a(class="btn btn-primary btn-block auth-button", href="login/reddit" disabled) + img(src='bootstrap/img/logo/reddit-sm-logo.png', width="30px",height="30px") + | Reddit Temporarily Not Accessible + img(src="bootstrap/img/logo/checkbox.png", class="export-success", width="30px", style="display:none;") button(id="auth-next", style="", class="pull-right") next diff --git a/www/views/search/query.pug b/www/views/search/query.pug index 7b0f9755..2467987a 100644 --- a/www/views/search/query.pug +++ b/www/views/search/query.pug @@ -68,12 +68,15 @@ html //div(class="twitter-auth",style="display:inline-block;") // a(target="_blank", href="login/twitter") // img(src='bootstrap/img/logo/twitter-sm-logo.png', width="30px",height="30px", style="margin-right:10px") - div(class="twitterV2-auth",style="display:inline-block;") - a(href="login/twitterV2") - img(src='bootstrap/img/logo/x-sm-logo.png', width="30px",height="30px", style="margin-right:10px") - div(class="reddit-auth",style="display:inline-block;") - a(href="login/reddit") - img(src='bootstrap/img/logo/reddit-sm-logo.png', width="30px",height="30px", style="margin-right:10px") + if TWITTER_ON + div(class="twitterV2-auth",style="display:inline-block;") + a(href="login/twitterV2") + img(src='bootstrap/img/logo/x-sm-logo.png', width="30px",height="30px", style="margin-right:10px") + if REDDIT_ON + div(class="reddit-auth",style="display:inline-block;") + a(href="login/reddit") + img(src='bootstrap/img/logo/reddit-sm-logo.png', width="30px",height="30px", style="margin-right:10px") + div(id="authorized",style="display:inline-block;") p(style="display:inline-block;margin:10px 10px;") You have already authorized: //img(id="twitter-authorized", src='bootstrap/img/logo/twitter-sm-logo.png', width="30px",height="30px", style="margin-right:10px;display:none;")