Skip to content

Instantly share code, notes, and snippets.

KacT9H

Block or report user

Report or block KacT9H

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View BitbucketApi.groovy
package net.realizeideas.oauth.bitbucket
import org.scribe.builder.api.DefaultApi10a
import org.scribe.model.Token
/**
* @author: Konstantin Khisamov
*/
class BitbucketApi extends DefaultApi10a {
View application.yml
oauth:
providers:
bitbucket: #provider name
api: net.realizeideas.oauth.bitbucket.BitbucketApi #API path, it will be implemented bellow
key: 'xxxxxF5DfBeK9xxxxx' #API key received in the previous step
secret: 'xxxxxxGZKY8xqNUkjCyY7xxxxxxxxxxx' #API secret received in the previous step
successUri: '/' #App will be redirected there after successful getting Access Token
failureUri: '/' #App will be redirected there after failed getting Access Token
callback: '${grails.serverURL}/oauth/bitbucket/callback' #Oauth Controller is provided by Oauth Plugin, so you need to set a provider name only
View resources.groovy
beans = {
localeResolver(CustomLocaleResolver)
//beans...
}
View HomeController.groovy
class HomeController {
def springSecurityService
//...
def changeLocale(String locale) {
def user = springSecurityService.currentUser as User
user.locale = new Locale(locale)
user.save()
//put locale to lang param
redirect action: 'index', params: [lang: locale]
View CustomLocaleResolver.groovy
class CustomLocaleResolver extends SessionLocaleResolver {
def springSecurityService = Holders.grailsApplication.mainContext.getBean('springSecurityService')
Locale resolveLocale(HttpServletRequest request) {
//getting locale from session
Locale locale = (Locale) WebUtils.getSessionAttribute(request, LOCALE_SESSION_ATTRIBUTE_NAME)
if (!locale) {
if (springSecurityService.isLoggedIn()) {
def user = springSecurityService.getCurrentUser() as User
locale = user.locale ?: determineDefaultLocale(request)
View User.groovy
class User {
String email
String password
Locale locale
// other fields
}
View page.html
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
%{--taggd path--}%
<link rel="stylesheet" href="your path/taggd-master/dist/taggd.css"/>
<script src="your path/taggd-master/dist/taggd.js"></script>
%{--custom styles path--}%
<link rel="stylesheet" href="your path/test.css"/>
</head>
View styles.css
.taggd-wrapper {
position: relative;
}
.taggd-wrapper .taggd-button {
background-color: transparent;
cursor: pointer;
border: 5px solid #bde0e1;
opacity: 0.2;
}
View Test weblow
def testFlow = {
//Any steps
renderView {
render(view: '/views/testView')
on('next-step').to "nextStep"
on('back').to "previousStep"
}
//Any steps
}
You can’t perform that action at this time.