Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/0.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
oBlissing committed Apr 16, 2015
2 parents f1b4880 + b8b7db9 commit a2c0c1e
Show file tree
Hide file tree
Showing 17 changed files with 210 additions and 86 deletions.
3 changes: 2 additions & 1 deletion config.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ MAIN_STATUS_MSG = {
"LEVEL": "WARNING",
"HEADER": "Observera",
"MESSAGE": "För att förenkla uppdatering och tester av katalogiseringsklienten så innehåller katalogen just nu en begränsad mängd poster."
}
}
ALWAYS_ALLOW_XLREG = 'False'
34 changes: 20 additions & 14 deletions kitin.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def get_requests_oauth():

def fake_login():
if hasattr(app, 'fakelogin') and app.fakelogin:
user = User('Fake banana', sigel='NONE')
app.logger.debug("Faking login %s %s", user.get_id(), user.get_sigel())
user = User('Fake banana', authorization=[{ 'sigel': 'NONE', 'xlreg': True, 'kat': True, 'reg': True }])
app.logger.debug("Faking login %s %s", user.get_id(), json.dumps(user.get_authorization()))
login_user(user, True)
session['sigel'] = user.sigel
session['authorization'] = user.authorization
return True
return False

Expand All @@ -87,18 +87,21 @@ def global_view_variables():

@login_manager.user_loader
def _load_user(uid):
if not 'sigel' in session:
if not 'authorization' in session:
return None
return User(uid, sigel=session.get('sigel'))
return User(uid, authorization=session.get('authorization'))


def _render_login(msg = None):
return render_template("partials/login.html", msg = msg, WHELK_HOST = app.config['WHELK_HOST'])

@login_manager.unauthorized_handler
def _handle_unauthorized():
# Redirect to "/login" removed. Since IE finds itself in an infinit loop
# trying to decide between /login and /#!/login
if fake_login():
return redirect('/')
return render_template("partials/login.html")
return _render_login()


# LOGIN START
Expand All @@ -107,7 +110,7 @@ def _handle_unauthorized():
def login():
if fake_login():
return redirect('/')
return render_template("partials/login.html")
return _render_login()

@app.route("/login/authorize")
def login_authorize():
Expand All @@ -119,7 +122,7 @@ def login_authorize():
return redirect(authorization_url)
except Exception, e:
app.logger.error("Failed to create authorization url, %s ", str(e))
return render_template("partials/login.html", msg = str(e))
return _render_login(str(e))

@app.route("/login/authorized")
def authorized():
Expand All @@ -144,14 +147,17 @@ def authorized():
varify_url = app.config['OAUTH_VERIFY_URL']
verify_response = requests_oauth.get(varify_url).json()
verify_user = verify_response['user']
sigel = verify_user['authorization'][0]['sigel']
authorization = verify_user['authorization']
username = verify_user['username']
if app.debug:
app.logger.debug("User received from verify %s, %s, %s ", username, sigel, json.dumps(verify_user))
app.logger.debug("User received from verify %s, %s, %s ", username, json.dumps(verify_user))

# Create Flask User and login
user = User(username, sigel=sigel, token=session['oauth_token'])
session['sigel'] = sigel
if(app.config.get('ALWAYS_ALLOW_XLREG') == 'True'):
for auth in authorization:
auth['xlreg'] = True;
user = User(username, authorization=authorization, token=session['oauth_token'])
session['authorization'] = authorization
login_user(user, True)

return redirect('/')
Expand All @@ -162,15 +168,15 @@ def authorized():
except Exception, e:
msg = str(e)
app.logger.error(msg)
return render_template("partials/login.html", msg = msg)
return _render_login(msg)


@app.route("/signout")
@login_required
def logout():
app.logger.debug("Trying to sign out...")
logout_user()
session.pop('sigel', None)
session.pop('authorization', None)
session.pop('oauth_token', None)
return redirect("/login")

Expand Down
18 changes: 17 additions & 1 deletion static/js/controllers/AppCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ kitin.controller('AppCtrl', function($scope, $rootScope, $modal, $timeout, $loca
jsonld: {}
};

$rootScope.globalAlert = {
msg : MAIN_STATUS_MSG.MESSAGE,
markRead : function () {
localStorage.setItem('MAIN_STATUS_MSG', $rootScope.globalAlert.msg);
$rootScope.globalAlert.read = true;
}
};
if($rootScope.globalAlert.msg === '' || localStorage.getItem('MAIN_STATUS_MSG') === $rootScope.globalAlert.msg)
{
$rootScope.globalAlert.read = true;
} else {
$rootScope.globalAlert.read = false;
}

window.toggleEdit = function () {
$rootScope.allowEdit = !$rootScope.allowEdit;
return $rootScope.allowEdit;
Expand Down Expand Up @@ -64,7 +78,9 @@ kitin.controller('AppCtrl', function($scope, $rootScope, $modal, $timeout, $loca
}
});
}

var searchParams = $location.search();

$rootScope.state = {
searchType: {},
remoteDatabases: [],
Expand All @@ -79,12 +95,12 @@ kitin.controller('AppCtrl', function($scope, $rootScope, $modal, $timeout, $loca
f: searchParams.f || null,
view: searchParams.view || 'detailed'
},


getSearchParams : function() {
var params = {
q: $rootScope.state.search.q,
start: $rootScope.state.search.page.start,
facets: searchService.searchTypeIndex.bib.facets,
n: $rootScope.state.search.n || searchService.getPageSize($rootScope.state.search.view),
sort: $rootScope.state.search.sort,
database: $rootScope.state.searchType.key === searchService.searchTypeIndex.remote.key ? $rootScope.state.search.database : undefined
Expand Down
10 changes: 7 additions & 3 deletions static/js/controllers/ModalJSONLDCtrl.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
kitin.controller('ModalJSONLDCtrl', function($scope, $modalInstance, $q, recordService, record) {
kitin.controller('ModalJSONLDCtrl', function($scope, $modalInstance, $q, recordService, editService, record) {

$scope.record = record;
var recordDataCopy = angular.copy(record);
editService.undecorate(recordDataCopy).then(function(undecoratedRecord) {
$scope.record = undecoratedRecord;
});

$scope.close = function() {
var deferred = $q.defer();
$modalInstance.close();
deferred.resolve();
return deferred.promise;
};
});

});
5 changes: 4 additions & 1 deletion static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ kitin.filter('unsafe', ['$sce', function ($sce) {
* (TODO: move to service and depend on in required places instead)
*/

kitin.run(function($rootScope, $location, $modalStack, $window, dialogs) {
kitin.run(function($rootScope, $location, $modalStack, $window, dialogs, userData) {
$rootScope.API_PATH = API_PATH;
$rootScope.WRITE_API_PATH = WHELK_WRITE_HOST;
$rootScope.MAIN_STATUS_MSG = MAIN_STATUS_MSG;
// Set current user, returned from back-end
userData.set(CURRENT_USER);
$rootScope.user = userData.get();

$rootScope.$on('$locationChangeStart', function (event) {
var closeModals = function(i) {
Expand Down
6 changes: 4 additions & 2 deletions static/js/services/SearchService.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ kitin.factory('searchService', function($http, $q, $rootScope, utilsService) {
return {
facetLabels: {
'about.@type': 'Typer',
'about.hasFormat.@type': 'Format',
'about.language.@id': 'Språk',
'encLevel.@id': 'Beskrivningsnivå'
},
searchTypeIndex: {
bib: {
key: 'bib',
label: 'Libris',
placeholder: 'Sök bland bibliografiskt material (på ISBN, titel, författare etc.)'
placeholder: 'Sök bland bibliografiskt material (på ISBN, titel, författare etc.)',
facets: ["about.@type", "about.hasFormat.@type", "about.language.@id"]
},
auth: {
key: 'auth',
Expand Down Expand Up @@ -60,4 +62,4 @@ kitin.factory('searchService', function($http, $q, $rootScope, utilsService) {
return deferred.promise;
}
};
});
});
25 changes: 24 additions & 1 deletion static/js/services/UserData.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,30 @@
* userData
*/
kitin.factory('userData', function() {
var username = null,
activeAuthorization = {}, // Active sigel authorization
authorization = []; // Users all authorizations
return {
userSigel: null

set: function(user) {
if(user) {
username = user.username;
if(user.authorization) {
authorization = user.authorization;
this.setActive(authorization[0].sigel);
}
}
return this;
},
get: function() {
var user = angular.copy(activeAuthorization);
user.username = username;
return user;
},
setActive: function(sigel) {
activeAuthorization = _.first(_.filter(authorization, function (auth) {
return auth.sigel === sigel;
}));
}
};
});
72 changes: 50 additions & 22 deletions static/less/jsonld.less
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

.json-ld .type {font-size: 12px; font-weight:600;color:@grey-very-dark;padding-left: 3px;}
.json-ld .header {font-size: 12px;}
.json-ld .label {font-size: 12px;display: block;background-color:@white;color:@grey-darker;margin-bottom:0px;padding:0px !important;}
.json-ld .label {font-size: 12px;display: block;color:@grey-darker;margin-bottom:0px;padding:0px !important;}

.collapsed > code {
background-color: @grey-light;
Expand Down Expand Up @@ -58,10 +58,15 @@

.json-ld .entity {
background-color: @white;
padding: 3px 15px 6px !important;
margin: 2px 2px 2px 6px !important;
border-radius: 3px;
box-shadow: 0 1px 5px rgba(0, 0, 0, .4);
padding: 0px 8px 0px;
margin: 2px 2px 2px 6px;
border-radius: 4px;
border-style: solid;
border-width: 1px 1px 1px 4px;
border-top-color: rgba(0, 0, 0, 0.25) !important;
border-bottom-color: rgba(0, 0, 0, 0.25) !important;
border-right-color: rgba(0, 0, 0, 0.25) !important;
// box-shadow: 0 1px 5px rgba(0, 0, 0, .4);
max-height: 2000em;
transition: max-height 0.25s ease-in-out;
overflow: hidden;
Expand All @@ -76,46 +81,69 @@
}

.json-ld .entity.linked {
border: 1px dashed rgba(0, 0, 0, 0.39);
box-shadow: inset 0px 0px 15px 0px rgba(0, 0, 0, 0.17) !important;
// background-color: desaturate(lighten(@green, 60%),50%);
// box-shadow: inset 0px 0px 15px 0px rgba(0, 0, 0, 0.1) !important;
}
.holdings .json-ld .entity.linked {
background-color: desaturate(lighten(@purple, 60%),20%);
border-color: @purple;
a {
color: @purple;
}
}

.collapsed > .entity {
max-height: 1.2em;
overflow: hidden;
box-shadow: inset 0px 5px 8px @white;
border: dotted @grey-light;
border-width: 1px 1px 1px 1px;
opacity: 0.4;

.bibview .json-ld .entity.linked {
background-color: desaturate(lighten(@green, 60%),50%);
border-color: @green;
a {
color: @green-dark;
}
}


.entity .btn-link {padding-left: 15px;}

section.json-ld {background-color:@white;}

div.array > .json-ld section.entity {
background-color: #fdfdfd;
box-shadow: 0 2px 10px 4px @grey-warm inset;
// box-shadow: 0 2px 10px 4px @grey-warm inset;
border-radius: 3px;
padding: 0px;
}

div.array > section {
margin: 0px 0px 3px 0px !important;
padding: 0px !important;
border-style: none !important;
background-color: transparent !important;
}

.collapsed > .entity {
max-height: 1.2em;
overflow: hidden;
// box-shadow: inset 0px 5px 8px @white;
// border: dotted @grey-light;
// border-width: 1px 1px 1px 1px;
border-bottom: 1px solid rgba(0, 0, 0, 0.5) !important;
border-radius: 4px 4px 0px 0px;
opacity: 0.4;
}

div.array {
overflow: hidden;
}

div.array > section.entity > div {
width: 50%;
width: 100%;
float: left;
margin: 0px 0;
position: relative;
}

section div.obj section div.obj section div.obj section div.obj {
width: 100%;
// background-color: purple;
}
// section div.obj section div.obj section div.obj section div.obj {
// width: 100%;
// // background-color: purple;
// }
div.array > section.entity > div:nth-of-type(even) {
float: right;
margin-bottom: none;
Expand Down
1 change: 1 addition & 0 deletions static/less/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ a.beta-blocker {text-decoration: none; cursor:default;}
background: @white;
position: absolute;
bottom: 0px;
height: 1em;
}
}

Expand Down
28 changes: 28 additions & 0 deletions static/less/startpage.less
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,32 @@ section.dash.drafts li{border-top: 1px solid @grey-light;padding-top:6px;
}
}

#GLOBAL_ALERT {
background-color: lighten(@green,2%);
width: 100%;
min-height: 55px;
color: white;
text-shadow: 0px 1px 5px rgba(0, 0, 0, 0.3);
padding: 10px 0px;
border: solid @green-dark;
border-width: 1px 0px;
div {
margin: auto;
text-align: center;
width: 1080px;
div {
width: 675px;
padding: 6px 0px 4px 0px;
}
}
p {
font-weight: bold;
text-align: center;
display: inline;
}
button {
float: right;
}
}

/* STARTPAGE END ------------------------- */
Loading

0 comments on commit a2c0c1e

Please sign in to comment.