Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
8b48d5ea
Commit
8b48d5ea
authored
Oct 02, 2017
by
Andrey Lugovskiy
Committed by
Matija Obreza
Oct 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Article#template are not indexed in ES
- added template to Article
parent
decc3ef4
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
208 additions
and
137 deletions
+208
-137
src/main/java/org/genesys2/server/model/elastic/FullTextDocument.java
...a/org/genesys2/server/model/elastic/FullTextDocument.java
+11
-0
src/main/java/org/genesys2/server/model/impl/Article.java
src/main/java/org/genesys2/server/model/impl/Article.java
+11
-0
src/main/java/org/genesys2/server/persistence/domain/ArticleRepository.java
...genesys2/server/persistence/domain/ArticleRepository.java
+4
-0
src/main/java/org/genesys2/server/service/ContentService.java
...main/java/org/genesys2/server/service/ContentService.java
+3
-4
src/main/java/org/genesys2/server/service/impl/ContentServiceImpl.java
.../org/genesys2/server/service/impl/ContentServiceImpl.java
+11
-8
src/main/java/org/genesys2/server/service/impl/CropServiceImpl.java
...ava/org/genesys2/server/service/impl/CropServiceImpl.java
+2
-1
src/main/java/org/genesys2/server/service/impl/EasySMTAMockConnector.java
...g/genesys2/server/service/impl/EasySMTAMockConnector.java
+1
-1
src/main/java/org/genesys2/server/service/impl/FullTextSearchServiceImpl.java
...nesys2/server/service/impl/FullTextSearchServiceImpl.java
+9
-10
src/main/java/org/genesys2/server/service/impl/GeoServiceImpl.java
...java/org/genesys2/server/service/impl/GeoServiceImpl.java
+3
-4
src/main/java/org/genesys2/server/service/impl/InstituteServiceImpl.java
...rg/genesys2/server/service/impl/InstituteServiceImpl.java
+2
-1
src/main/java/org/genesys2/server/service/impl/OrganizationServiceImpl.java
...genesys2/server/service/impl/OrganizationServiceImpl.java
+2
-1
src/main/java/org/genesys2/server/service/impl/ProjectServiceImpl.java
.../org/genesys2/server/service/impl/ProjectServiceImpl.java
+2
-1
src/main/java/org/genesys2/server/servlet/controller/ArticleController.java
...genesys2/server/servlet/controller/ArticleController.java
+17
-12
src/main/java/org/genesys2/server/servlet/controller/GeoRegionController.java
...nesys2/server/servlet/controller/GeoRegionController.java
+2
-2
src/main/resources/content/language.properties
src/main/resources/content/language.properties
+1
-0
src/main/resources/content/language_ar.properties
src/main/resources/content/language_ar.properties
+1
-0
src/main/resources/content/language_de.properties
src/main/resources/content/language_de.properties
+1
-0
src/main/resources/content/language_es.properties
src/main/resources/content/language_es.properties
+1
-0
src/main/resources/content/language_fa.properties
src/main/resources/content/language_fa.properties
+1
-0
src/main/resources/content/language_fr.properties
src/main/resources/content/language_fr.properties
+1
-0
src/main/resources/content/language_pt.properties
src/main/resources/content/language_pt.properties
+1
-0
src/main/resources/content/language_ru.properties
src/main/resources/content/language_ru.properties
+1
-0
src/main/resources/content/language_zh.properties
src/main/resources/content/language_zh.properties
+1
-0
src/main/resources/liquibase/liquibase-changeLog.yml
src/main/resources/liquibase/liquibase-changeLog.yml
+12
-0
src/main/sourceapp/1/styles/genesys.scss
src/main/sourceapp/1/styles/genesys.scss
+1
-0
src/main/webapp/WEB-INF/jsp/content/article-edit.jsp
src/main/webapp/WEB-INF/jsp/content/article-edit.jsp
+102
-89
src/main/webapp/WEB-INF/jsp/content/article.jsp
src/main/webapp/WEB-INF/jsp/content/article.jsp
+3
-2
src/test/java/org/genesys2/tests/unit/ContentServiceTest.java
...test/java/org/genesys2/tests/unit/ContentServiceTest.java
+1
-1
No files found.
src/main/java/org/genesys2/server/model/elastic/FullTextDocument.java
View file @
8b48d5ea
...
...
@@ -53,9 +53,20 @@ public class FullTextDocument {
@Field
(
index
=
FieldIndex
.
not_analyzed
,
type
=
FieldType
.
Date
)
private
Date
lastModifiedDate
;
@Field
(
type
=
FieldType
.
Boolean
)
private
Boolean
template
;
/** The score here will boost result relevance */
private
Float
score
=
0.5f
;
public
Boolean
getTemplate
()
{
return
template
;
}
public
void
setTemplate
(
Boolean
template
)
{
this
.
template
=
template
;
}
public
Long
getId
()
{
return
this
.
id
;
}
...
...
src/main/java/org/genesys2/server/model/impl/Article.java
View file @
8b48d5ea
...
...
@@ -69,6 +69,17 @@ public class Article extends AuditedModel {
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Calendar
postDate
;
@Column
(
nullable
=
false
,
columnDefinition
=
"boolean default false"
)
private
boolean
template
;
public
boolean
isTemplate
()
{
return
template
;
}
public
void
setTemplate
(
boolean
template
)
{
this
.
template
=
template
;
}
public
String
getSlug
()
{
return
slug
;
}
...
...
src/main/java/org/genesys2/server/persistence/domain/ArticleRepository.java
View file @
8b48d5ea
...
...
@@ -24,6 +24,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
java.util.List
;
public
interface
ArticleRepository
extends
JpaRepository
<
Article
,
Long
>
{
Article
findByClassPkAndTargetIdAndSlugAndLang
(
ClassPK
classPk
,
Long
id
,
String
slug
,
String
lang
);
...
...
@@ -37,4 +39,6 @@ public interface ArticleRepository extends JpaRepository<Article, Long> {
Article
findBySlugAndLangAndTargetIdAndClassPk
(
String
slug
,
String
lang
,
Long
targetId
,
ClassPK
classPK
);
@Query
(
"select a from Article a where a.template = :isTemplate"
)
List
<
Article
>
findAllByTemplate
(
@Param
(
"isTemplate"
)
Boolean
isTemplate
);
}
src/main/java/org/genesys2/server/service/ContentService.java
View file @
8b48d5ea
...
...
@@ -46,7 +46,6 @@ public interface ContentService {
* Load article with {@link ClassPK} of clazz with specified id and the
* "slug" for the locale
*
* @param target
* @param slug
* @param locale
* @return
...
...
@@ -95,11 +94,11 @@ public interface ContentService {
*/
ActivityPost
createActivityPost
(
String
title
,
String
body
);
Article
updateArticle
(
EntityId
entity
,
String
slug
,
String
title
,
String
body
,
String
summary
,
Locale
locale
);
Article
updateArticle
(
EntityId
entity
,
String
slug
,
String
title
,
String
body
,
String
summary
,
Locale
locale
,
Boolean
isTemplate
);
Article
updateArticle
(
Class
<?>
clazz
,
Long
id
,
String
slug
,
String
title
,
String
body
,
String
summary
,
Locale
locale
);
Article
updateArticle
(
Class
<?>
clazz
,
Long
id
,
String
slug
,
String
title
,
String
body
,
String
summary
,
Locale
locale
,
Boolean
isTemplate
);
Article
updateArticle
(
long
id
,
String
slug
,
String
title
,
String
body
,
String
summary
);
Article
updateArticle
(
long
id
,
String
slug
,
String
title
,
String
body
,
String
summary
,
Boolean
isTemplate
);
Article
updateGlobalArticle
(
String
slug
,
Locale
locale
,
String
title
,
String
body
,
String
summary
);
...
...
src/main/java/org/genesys2/server/service/impl/ContentServiceImpl.java
View file @
8b48d5ea
...
...
@@ -165,16 +165,15 @@ public class ContentServiceImpl implements ContentService {
@Transactional
(
readOnly
=
false
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasRole('CONTENTMANAGER')"
)
@CacheEvict
(
value
=
"contentcache"
,
allEntries
=
true
)
public
Article
updateArticle
(
long
id
,
String
slug
,
String
title
,
String
body
,
String
summary
)
{
public
Article
updateArticle
(
long
id
,
String
slug
,
String
title
,
String
body
,
String
summary
,
Boolean
isTemplate
)
{
final
Article
article
=
articleRepository
.
findOne
(
id
);
article
.
setSlug
(
slug
);
article
.
setTitle
(
htmlSanitizer
.
sanitize
(
title
));
article
.
setSummary
(
htmlSanitizer
.
sanitize
(
summary
));
article
.
setTemplate
(
isTemplate
);
// FIXME TODO Find a better way to distinguish between Velocity
// templates and general articles
if
(
StringUtils
.
contains
(
body
,
"VELOCITY"
))
{
if
(
isTemplate
)
{
article
.
setBody
(
body
);
}
else
{
article
.
setBody
(
htmlSanitizer
.
sanitize
(
body
));
...
...
@@ -218,18 +217,18 @@ public class ContentServiceImpl implements ContentService {
@Transactional
(
readOnly
=
false
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasRole('CONTENTMANAGER') or hasPermission(#entity, 'ADMINISTRATION')"
)
@CacheEvict
(
value
=
"contentcache"
,
allEntries
=
true
)
public
Article
updateArticle
(
EntityId
entity
,
String
slug
,
String
title
,
String
body
,
String
summary
,
Locale
locale
)
{
public
Article
updateArticle
(
EntityId
entity
,
String
slug
,
String
title
,
String
body
,
String
summary
,
Locale
locale
,
Boolean
isTemplate
)
{
// return
// articleRepository.findByClassPkAndTargetIdAndSlugAndLang(getClassPk(clazz),
// id, slug, locale.getLanguage());
return
updateArticle
(
entity
.
getClass
(),
entity
.
getId
(),
slug
,
title
,
body
,
summary
,
locale
);
return
updateArticle
(
entity
.
getClass
(),
entity
.
getId
(),
slug
,
title
,
body
,
summary
,
locale
,
isTemplate
);
}
@Override
@Transactional
(
readOnly
=
false
)
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasRole('CONTENTMANAGER')"
)
@CacheEvict
(
value
=
"contentcache"
,
allEntries
=
true
)
public
Article
updateArticle
(
Class
<?>
clazz
,
Long
id
,
String
slug
,
String
title
,
String
body
,
String
summary
,
Locale
locale
)
{
public
Article
updateArticle
(
Class
<?>
clazz
,
Long
id
,
String
slug
,
String
title
,
String
body
,
String
summary
,
Locale
locale
,
Boolean
isTemplate
)
{
Article
article
=
getArticle
(
clazz
,
id
,
slug
,
locale
,
false
);
if
(
article
==
null
||
!
article
.
getLang
().
equals
(
locale
.
getLanguage
()))
{
article
=
new
Article
();
...
...
@@ -239,7 +238,11 @@ public class ContentServiceImpl implements ContentService {
article
.
setPostDate
(
Calendar
.
getInstance
());
article
.
setSlug
(
slug
);
}
article
.
setBody
(
htmlSanitizer
.
sanitize
(
body
));
if
(
isTemplate
)
{
article
.
setBody
(
body
);
}
else
{
article
.
setBody
(
htmlSanitizer
.
sanitize
(
body
));
}
article
.
setSummary
(
htmlSanitizer
.
sanitize
(
summary
));
article
.
setTitle
(
htmlSanitizer
.
sanitize
(
title
));
...
...
src/main/java/org/genesys2/server/service/impl/CropServiceImpl.java
View file @
8b48d5ea
...
...
@@ -113,7 +113,8 @@ public class CropServiceImpl implements CropService {
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasRole('CONTENTMANAGER') or hasPermission(#crop, 'ADMINISTRATION')"
)
@Transactional
(
readOnly
=
false
)
public
void
updateBlurp
(
Crop
crop
,
String
textBody
,
String
summary
,
Locale
locale
)
{
contentService
.
updateArticle
(
crop
,
"blurp"
,
null
,
textBody
,
summary
,
locale
);
//isTemplate = false because it's crop
contentService
.
updateArticle
(
crop
,
"blurp"
,
null
,
textBody
,
summary
,
locale
,
false
);
}
@Override
...
...
src/main/java/org/genesys2/server/service/impl/EasySMTAMockConnector.java
View file @
8b48d5ea
...
...
@@ -24,7 +24,7 @@ import org.genesys2.server.service.EasySMTA;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.stereotype.Component
;
@Profile
({
"dev"
})
//
@Profile({ "dev" })
@Component
public
class
EasySMTAMockConnector
implements
EasySMTA
{
private
static
final
Log
LOG
=
LogFactory
.
getLog
(
EasySMTAMockConnector
.
class
);
...
...
src/main/java/org/genesys2/server/service/impl/FullTextSearchServiceImpl.java
View file @
8b48d5ea
...
...
@@ -66,6 +66,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
private
static
final
String
ACCESSION_SECTION
=
"accession"
;
private
static
final
String
CLASSPK_SHORTNAME
=
"classPK.shortName"
;
private
static
final
Boolean
DEFAULT_ARTICLE_TEMPLATE
=
false
;
@Autowired
private
ElasticsearchTemplate
elasticsearchTemplate
;
...
...
@@ -141,12 +142,11 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
SearchQuery
searchQuery
=
new
NativeSearchQueryBuilder
()
.
withIndices
(
IndexAliasConstants
.
INDEXALIAS_FULLTEXT_READ
)
.
withQuery
(
functionScoreQuery
(
boolQuery
().
must
(
matchQuery
(
CLASSPK_SHORTNAME
,
classPK
.
getShortName
())).
must
(
queryStringQuery
(
query
).
defaultOperator
(
QueryStringQueryBuilder
.
Operator
.
AND
))).
add
(
fieldValueFactorFunction
(
"score"
).
factor
(
1.0f
))).
withPageable
(
pageable
).
build
();
.
withQuery
(
functionScoreQuery
(
boolQuery
()
.
must
(
matchQuery
(
CLASSPK_SHORTNAME
,
classPK
.
getShortName
()))
.
must
(
queryStringQuery
(
query
).
defaultOperator
(
QueryStringQueryBuilder
.
Operator
.
AND
)))
.
add
(
fieldValueFactorFunction
(
"score"
).
factor
(
1.0f
)))
.
withPageable
(
pageable
).
build
();
try
{
FacetedPage
<
FullTextDocument
>
fulltextResults
=
this
.
elasticsearchTemplate
.
queryForPage
(
searchQuery
,
FullTextDocument
.
class
);
return
toEntities
(
fulltextResults
,
pageable
);
...
...
@@ -211,9 +211,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
public
List
<
FullTextDocument
>
getFullTextDocuments
(
final
String
className
,
final
Collection
<
Long
>
ids
)
{
final
List
<
BasicModel
>
models
=
new
ArrayList
<>(
ids
.
size
());
// TODO Only include global articles, exclude "blurbs"
models
.
addAll
(
this
.
articleRepository
.
findAll
(
ids
));
models
.
addAll
(
this
.
articleRepository
.
findAllByTemplate
(
DEFAULT_ARTICLE_TEMPLATE
));
// Posts are only in "en"
models
.
addAll
(
this
.
postRepository
.
findAll
(
ids
));
models
.
addAll
(
this
.
countryRepository
.
findAll
(
ids
));
...
...
@@ -289,7 +287,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
/**
* TODO FIXME
*
*
* @param model
* @return
*/
...
...
@@ -304,6 +302,7 @@ public class FullTextSearchServiceImpl implements FullTextSearchService, Initial
// countries
final
Article
article
=
(
Article
)
model
;
document
.
setBody
(
article
.
getBody
());
document
.
setTemplate
(
article
.
isTemplate
());
document
.
setSummary
(
article
.
getSummary
());
document
.
setLanguage
(
article
.
getLang
());
document
.
setCreatedDate
(
article
.
getCreatedDate
());
...
...
src/main/java/org/genesys2/server/service/impl/GeoServiceImpl.java
View file @
8b48d5ea
...
...
@@ -154,9 +154,7 @@ public class GeoServiceImpl implements GeoService {
/**
* Check if we have a country that has
*
* @param name
* in i18n
* @param countryString
* @param name in i18n
* @return
*/
private
Country
findCountryByName
(
String
name
)
{
...
...
@@ -363,7 +361,8 @@ public class GeoServiceImpl implements GeoService {
@Transactional
(
readOnly
=
false
)
public
void
updateBlurp
(
Country
country
,
String
blurp
,
Locale
locale
)
{
// TODO Should we provide summary?
contentService
.
updateArticle
(
country
,
"blurp"
,
null
,
blurp
,
null
,
locale
);
//isTemplate = false because it's country.
contentService
.
updateArticle
(
country
,
"blurp"
,
null
,
blurp
,
null
,
locale
,
false
);
}
@Override
...
...
src/main/java/org/genesys2/server/service/impl/InstituteServiceImpl.java
View file @
8b48d5ea
...
...
@@ -139,7 +139,8 @@ public class InstituteServiceImpl implements InstituteService {
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasPermission(#faoInstitute, 'ADMINISTRATION')"
)
@Transactional
(
readOnly
=
false
)
public
void
updateAbout
(
FaoInstitute
faoInstitute
,
String
body
,
String
summary
,
Locale
locale
)
{
contentService
.
updateArticle
(
faoInstitute
,
"blurp"
,
null
,
body
,
summary
,
locale
);
//isTemplate = false because it's institute.
contentService
.
updateArticle
(
faoInstitute
,
"blurp"
,
null
,
body
,
summary
,
locale
,
false
);
}
@Override
...
...
src/main/java/org/genesys2/server/service/impl/OrganizationServiceImpl.java
View file @
8b48d5ea
...
...
@@ -86,7 +86,8 @@ public class OrganizationServiceImpl implements OrganizationService {
@PreAuthorize
(
"hasRole('ADMINISTRATOR')"
)
@Transactional
(
readOnly
=
false
)
public
Article
updateAbout
(
Organization
organization
,
String
body
,
String
summary
,
Locale
locale
)
{
return
contentService
.
updateArticle
(
organization
,
"blurp"
,
null
,
body
,
summary
,
locale
);
//isTemplate = false because it's organization.
return
contentService
.
updateArticle
(
organization
,
"blurp"
,
null
,
body
,
summary
,
locale
,
false
);
}
@Override
...
...
src/main/java/org/genesys2/server/service/impl/ProjectServiceImpl.java
View file @
8b48d5ea
...
...
@@ -85,6 +85,7 @@ public class ProjectServiceImpl implements ProjectService {
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasRole('CONTENTMANAGER') or hasPermission(#project, 'ADMINISTRATION')"
)
@Transactional
public
void
updateBlurp
(
Project
project
,
String
textBody
,
String
summary
,
Locale
locale
)
{
contentService
.
updateArticle
(
project
,
"blurp"
,
null
,
textBody
,
summary
,
locale
);
//isTemplate = false because it's project.
contentService
.
updateArticle
(
project
,
"blurp"
,
null
,
textBody
,
summary
,
locale
,
false
);
}
}
src/main/java/org/genesys2/server/servlet/controller/ArticleController.java
View file @
8b48d5ea
...
...
@@ -25,6 +25,7 @@ import java.util.Set;
import
java.util.TreeMap
;
import
javax.annotation.Resource
;
import
javax.naming.NoPermissionException
;
import
org.apache.commons.lang.StringUtils
;
import
org.genesys.blocks.model.ClassPK
;
...
...
@@ -40,6 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
...
...
@@ -143,8 +145,6 @@ public class ArticleController extends BaseController {
* Fetch all from Transifex and store
*
* @param slug
* @param language
* @param model
* @return
* @throws Exception
*/
...
...
@@ -152,7 +152,7 @@ public class ArticleController extends BaseController {
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasRole('CONTENTMANAGER')"
)
public
String
fetchAllFromTransifex
(
RedirectAttributes
redirectAttrs
,
@RequestParam
(
"slug"
)
String
slug
,
@RequestParam
(
value
=
"targetId"
,
required
=
false
)
Long
targetId
,
@RequestParam
(
value
=
"classPkShortName"
,
required
=
false
)
String
classPkShortName
)
throws
Exception
{
@RequestParam
(
value
=
"classPkShortName"
,
required
=
false
)
String
classPkShortName
,
@RequestParam
(
name
=
"template"
,
defaultValue
=
"false"
)
Boolean
template
)
throws
Exception
{
if
(
transifexService
==
null
)
{
throw
new
ResourceNotFoundException
(
"translationService not enabled"
);
...
...
@@ -211,7 +211,7 @@ public class ArticleController extends BaseController {
if
(
targetId
!=
null
&&
StringUtils
.
isNotBlank
(
classPkShortName
))
{
ClassPK
classPk
=
contentService
.
getClassPk
(
classPkShortName
);
contentService
.
updateArticle
(
Class
.
forName
(
classPk
.
getClassname
()),
targetId
,
slug
,
title
,
body
,
summary
,
new
Locale
(
lang
));
contentService
.
updateArticle
(
Class
.
forName
(
classPk
.
getClassname
()),
targetId
,
slug
,
title
,
body
,
summary
,
new
Locale
(
lang
)
,
template
);
responses
.
add
(
"article.translations-updated"
);
}
else
if
(
targetId
==
null
&&
StringUtils
.
isBlank
(
classPkShortName
))
{
contentService
.
updateGlobalArticle
(
slug
,
locale
,
title
,
body
,
summary
);
...
...
@@ -277,7 +277,7 @@ public class ArticleController extends BaseController {
}
@RequestMapping
(
"{slug:.+}"
)
public
String
view
(
ModelMap
model
,
@PathVariable
(
value
=
"slug"
)
String
slug
)
{
public
String
view
(
ModelMap
model
,
@PathVariable
(
value
=
"slug"
)
String
slug
)
throws
NoPermissionException
{
_logger
.
debug
(
"Viewing article "
+
slug
);
final
Article
article
=
contentService
.
getGlobalArticle
(
slug
,
getLocale
());
...
...
@@ -286,6 +286,10 @@ public class ArticleController extends BaseController {
return
"redirect:/content/edit/"
+
slug
+
"/"
+
LocaleContextHolder
.
getLocale
().
getLanguage
();
}
throw
new
ResourceNotFoundException
();
}
else
{
if
(
article
.
isTemplate
()
&&
!
hasRole
(
"ADMINISTRATOR"
)
&&
!
hasRole
(
"CONTENTMANAGER"
)){
throw
new
AccessDeniedException
(
"You do not have permission to access the resource"
);
}
}
model
.
addAttribute
(
"title"
,
article
.
getTitle
());
model
.
addAttribute
(
"article"
,
article
);
...
...
@@ -294,7 +298,7 @@ public class ArticleController extends BaseController {
}
@RequestMapping
(
"{menu}/{url:.+}"
)
public
String
viewWithMenu
(
ModelMap
model
,
@PathVariable
(
value
=
"menu"
)
String
menuKey
,
@PathVariable
(
value
=
"url"
)
String
slug
)
{
public
String
viewWithMenu
(
ModelMap
model
,
@PathVariable
(
value
=
"menu"
)
String
menuKey
,
@PathVariable
(
value
=
"url"
)
String
slug
)
throws
NoPermissionException
{
String
result
=
view
(
model
,
slug
);
if
(
StringUtils
.
isNotBlank
(
menuKey
))
{
_logger
.
debug
(
"Loading menu "
+
menuKey
);
...
...
@@ -346,7 +350,6 @@ public class ArticleController extends BaseController {
*
* @param model
* @param slug
* @param shortName
* @param targetId
* @param language
* @return
...
...
@@ -364,6 +367,7 @@ public class ArticleController extends BaseController {
article
.
setSlug
(
slug
);
article
.
setLang
(
language
);
article
.
setTargetId
(
targetId
);
article
.
setTemplate
(
article
.
isTemplate
());
article
.
setClassPk
(
contentService
.
getClassPk
(
classPkShortName
));
}
model
.
addAttribute
(
"article"
,
article
);
...
...
@@ -374,7 +378,8 @@ public class ArticleController extends BaseController {
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasRole('CONTENTMANAGER')"
)
@RequestMapping
(
value
=
"/save-article/{language}"
,
method
=
{
RequestMethod
.
POST
})
public
String
createNewGlobalArticle
(
ModelMap
model
,
@RequestParam
(
"slug"
)
String
slug
,
@PathVariable
(
"language"
)
String
language
,
@RequestParam
(
"title"
)
String
title
,
@RequestParam
(
"body"
)
String
body
,
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
)
{
@RequestParam
(
"title"
)
String
title
,
@RequestParam
(
"body"
)
String
body
,
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
,
@RequestParam
(
name
=
"template"
,
defaultValue
=
"false"
)
Boolean
template
)
{
Article
article
=
contentService
.
updateGlobalArticle
(
slug
,
new
Locale
(
language
),
title
,
body
,
summary
);
return
redirectAfterSave
(
article
,
language
);
...
...
@@ -384,9 +389,9 @@ public class ArticleController extends BaseController {
@RequestMapping
(
value
=
"/save-article/{language}"
,
params
=
{
"id"
},
method
=
{
RequestMethod
.
POST
})
public
String
saveExistingGlobalArticle
(
ModelMap
model
,
@PathVariable
(
"language"
)
String
language
,
@RequestParam
(
"id"
)
long
id
,
@RequestParam
(
"slug"
)
String
slug
,
@RequestParam
(
"title"
)
String
title
,
@RequestParam
(
"body"
)
String
body
,
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
)
{
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
,
@RequestParam
(
name
=
"template"
,
defaultValue
=
"false"
)
Boolean
template
)
{
Article
article
=
contentService
.
updateArticle
(
id
,
slug
,
title
,
body
,
summary
);
Article
article
=
contentService
.
updateArticle
(
id
,
slug
,
title
,
body
,
summary
,
template
);
return
redirectAfterSave
(
article
,
language
);
}
...
...
@@ -394,10 +399,10 @@ public class ArticleController extends BaseController {
@RequestMapping
(
value
=
"/save-article/{language}"
,
params
=
{
"classPkShortName"
,
"targetId"
},
method
=
{
RequestMethod
.
POST
})
public
String
saveNewClassPkArticle
(
ModelMap
model
,
@PathVariable
(
"language"
)
String
language
,
@RequestParam
(
"classPkShortName"
)
String
classPkShortName
,
@RequestParam
(
"targetId"
)
long
entityId
,
@RequestParam
(
"slug"
)
String
slug
,
@RequestParam
(
"title"
)
String
title
,
@RequestParam
(
"body"
)
String
body
,
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
)
throws
ClassNotFoundException
{
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
,
@RequestParam
(
name
=
"template"
,
defaultValue
=
"false"
)
Boolean
template
)
throws
ClassNotFoundException
{
ClassPK
classPk
=
contentService
.
getClassPk
(
classPkShortName
);
Article
article
=
contentService
.
updateArticle
(
Class
.
forName
(
classPk
.
getClassname
()),
entityId
,
slug
,
title
,
body
,
summary
,
new
Locale
(
language
));
Article
article
=
contentService
.
updateArticle
(
Class
.
forName
(
classPk
.
getClassname
()),
entityId
,
slug
,
title
,
body
,
summary
,
new
Locale
(
language
)
,
template
);
return
redirectAfterSave
(
article
,
language
);
}
...
...
src/main/java/org/genesys2/server/servlet/controller/GeoRegionController.java
View file @
8b48d5ea
...
...
@@ -80,8 +80,8 @@ public class GeoRegionController extends BaseController {
if
(
region
==
null
)
{
throw
new
ResourceNotFoundException
();
}
contentService
.
updateArticle
(
region
,
"blurp"
,
null
,
body
,
summary
,
getLocale
());
//isTemplate = false because it's region.
contentService
.
updateArticle
(
region
,
"blurp"
,
null
,
body
,
summary
,
getLocale
()
,
false
);
return
"redirect:/geo/regions/"
+
code
;
}
...
...
src/main/resources/content/language.properties
View file @
8b48d5ea
...
...
@@ -882,3 +882,4 @@ welcome.search-genesys=Search Genesys
welcome.networks
=
Networks
geo.country
=
Country:
article.is.template
=
Is template:
src/main/resources/content/language_ar.properties
View file @
8b48d5ea
...
...
@@ -858,3 +858,4 @@ welcome.search-genesys=البحث في جينيسيس
welcome.networks
=
الشبكات
geo.country
=
الدولة:
article.is.template
=
هو القالب:
src/main/resources/content/language_de.properties
View file @
8b48d5ea
...
...
@@ -858,3 +858,4 @@ welcome.search-genesys=Genesys durchsuchen
welcome.networks
=
Netzwerke
geo.country
=
Land:
article.is.template
=
Ist Vorlage:
src/main/resources/content/language_es.properties
View file @
8b48d5ea
...
...
@@ -858,3 +858,4 @@ welcome.search-genesys=Buscar en Genesys
welcome.networks
=
Redes
geo.country
=
País:
article.is.template
=
Es plantilla:
src/main/resources/content/language_fa.properties
View file @
8b48d5ea
...
...
@@ -858,3 +858,4 @@ welcome.search-genesys=جستجو در Genesys
welcome.networks
=
شبکهها
geo.country
=
کشور:
article.is.template
=
الگو است:
src/main/resources/content/language_fr.properties
View file @
8b48d5ea
...
...
@@ -858,3 +858,4 @@ welcome.search-genesys=Recherche sur Genesys
welcome.networks
=
Réseaux
geo.country
=
Pays :
article.is.template
=
Est-ce que le modèle:
src/main/resources/content/language_pt.properties
View file @
8b48d5ea
...
...
@@ -858,3 +858,4 @@ welcome.search-genesys=Pesquisar no Genesys
welcome.networks
=
Redes
geo.country
=
País:
article.is.template
=
É modelo:
src/main/resources/content/language_ru.properties
View file @
8b48d5ea
...
...
@@ -858,3 +858,4 @@ welcome.search-genesys=Поиск по Genesys
welcome.networks
=
Сети
geo.country
=
Страна:
article.is.template
=
Шаблон:
src/main/resources/content/language_zh.properties
View file @
8b48d5ea
...
...
@@ -858,3 +858,4 @@ welcome.search-genesys=搜索Genesys
welcome.networks
=
网站
geo.country
=
国家/地区:
article.is.template
=
是模板
src/main/resources/liquibase/liquibase-changeLog.yml
View file @
8b48d5ea
...
...
@@ -680,3 +680,15 @@ databaseChangeLog:
-
column
:
name
:
username
type
:
varchar(100)
-
changeSet
:
id
:
1506155384557-6
author
:
a.lugovskiy (generated)
changes
:
-
addColumn
:
tableName
:
article
columns
:
-
column
:
name
:
template
type
:
boolean
defaultValue
:
false
src/main/sourceapp/1/styles/genesys.scss
View file @
8b48d5ea
...
...
@@ -1582,6 +1582,7 @@ form.form-horizontal .form-group {
&
>
div
{
html
[
dir
=
"ltr"
]
&
{
border-left
:
2px
solid
#E7E5DF
;
min-height
:
66px
;
}
html
[
dir
=
"rtl"
]
&
{
border-right
:
2px
solid
#E7E5DF
;
...
...
src/main/webapp/WEB-INF/jsp/content/article-edit.jsp
View file @
8b48d5ea
...
...
@@ -5,99 +5,112 @@
<html>
<head>
<title><c:out
value=
"
${
title
}
"
/></title>
<title><c:out
value=
"
${
title
}
"
/></title>
</head>
<body
class=
"article-page selected-list"
>
<h1
class=
"green-bg"
>
<spring:message
code=
"article.edit-article"
/>
</h1>
<%@ include
file=
"transifex-responses.jspf"
%>
<c:set
var=
"url"
value=
"/content/save-article/${article.lang}"
/>
<c:set
var=
"cancel"
value=
"
${
article
.
id
ne
null
?
(
article
.
targetId
ne
null
?
'/content/'
.
concat
(
article
.
slug
).
concat
(
'/'
).
concat
(
article
.
classPk
.
shortName
).
concat
(
'/'
).
concat
(
article
.
targetId
).
concat
(
'/'
).
concat
(
article
.
lang
)
:
'/content/'
.
concat
(
article
.
slug
))
:
'/content'
}
"
/>
<c:if
test=
"
${
article
.
lang
eq
'en'
}
"
>
<div
class=
"row main-col-header clearfix"
>
<form
method=
"post"
action=
"
<c:url
value=
"/content/transifex"
/>
"
>
<input
type=
"hidden"
name=
"slug"
class=
"btn btn-default"
value=
"${article.slug}"
/>
<input
type=
"hidden"
name=
"targetId"
class=
"btn btn-default"
value=
"${article.targetId}"
/>
<input
type=
"hidden"
name=
"classPkShortName"
class=
"btn btn-default"
value=
"${article.classPk.shortName}"
/>
<input
type=
"submit"
name=
"post"
class=
"btn btn-default"
value=
"
<spring:message
code=
"article.post-to-transifex"
/>
"
/>
<input
type=
"submit"
name=
"remove"
class=
"btn btn-default"
value=
"
<spring:message
code=
"article.remove-from-transifex"
/>
"
/>
<input
type=
"submit"
name=
"fetch-all"
class=
"btn btn-default"
value=
"
<spring:message
code=
"article.fetch-from-transifex"
/>
"
/>
<!-- CSRF protection -->
<input
type=
"hidden"
name=
"${_csrf.parameterName}"
value=
"${_csrf.token}"
/>
</form>
</div>
<div><c:out
value=
"
${
resource
}
"
/></div>
</c:if>
<form
dir=
"${article.lang=='fa' || article.lang=='ar' ? 'rtl' : 'ltr'}"
role=
"form"
id=
"editForm"
class=
"form-horizontal"
action=
"
<c:url
value=
"
${
url
}
"
/>
"
method=
"post"
>
<c:choose>
<c:when
test=
"
${
article
.
id
gt
0
}
"
>
<input
type=
"hidden"
name=
"id"
value=
"${article.id}"
/>
</c:when>
<c:when
test=
"
${
article
.
targetId
ne
null
}
"
>
<input
type=
"hidden"
name=
"targetId"
value=
"${article.targetId}"
/>
<input
type=
"hidden"
name=
"classPkShortName"
value=
"${article.classPk.shortName}"
/>
</c:when>
</c:choose>
<div
class=
"form-group"
>
<label
for=
"article-slug"
class=
"col-lg-2 col-md-3 col-sm-3 col-xs-12 control-label"
>
<spring:message
code=
"article.slug"
/>
</label>
<div
class=
"col-lg-10 col-md-9 col-sm-9 col-xs-12 controls"
>
<input
type=
"text"
id=
"article-slug"
name=
"slug"
value=
"
<c:out
value=
"
${
article
.
slug
}
"
/>
"
class=
"span9 form-control required"
/>
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"article-title"
class=
"col-lg-2 col-md-3 col-sm-3 col-xs-12 control-label"
>
<spring:message
code=
"article.title"
/>
</label>
<div
class=
"col-lg-10 col-md-9 col-sm-9 col-xs-12 controls"
>
<input
type=
"text"
id=
"article-title"
name=
"title"
value=
"
<c:out
value=
"
${
article
.
title
}
"
/>
"
class=
"span9 form-control required"
/>
</div>
</div>
<div
dir=
"${article.lang=='fa' || article.lang=='ar' ? 'rtl' : 'ltr'}"
class=
"form-group"
>
<label
for=
"article-body"
class=
"control-label"
>
<spring:message
code=
"article.body"
/>
</label>
<div
class=
"controls"
>
<textarea
id=
"article-body"
name=
"body"
class=
"span9 required form-control html-editor"
><c:out
value=
"
${
article
.
body
}
"
escapeXml=
"false"
/></textarea>
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"article-summary"
class=
"control-label"
>
<spring:message
code=
"article.summary"
/>
</label>
<div
class=
"controls"
>
<textarea
id=
"article-summary"
name=
"summary"
class=
"span9 required form-control html-editor"
><c:out
value=
"
${
article
.
summary
}
"
escapeXml=
"false"
/></textarea>
</div>
</div>
<div
class=
"form-group transparent"
>
<input
type=
"submit"
value=
"
<spring:message
code=
"save"
/>
"
class=
"btn btn-primary"
/>
<a
href=
"
<c:url
value=
"
${
cancel
}
"
/>
"
class=
"btn btn-default"
>
Cancel
</a>
</div>
<!-- CSRF protection -->
<input
type=
"hidden"
name=
"${_csrf.parameterName}"
value=
"${_csrf.token}"
/>
</form>
<content
tag=
"javascript"
>
<h1
class=
"green-bg"
>
<spring:message
code=
"article.edit-article"
/>
</h1>