Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo
Commits
1b1767ca
Commit
1b1767ca
authored
May 31, 2014
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #11976
parent
e729c4d8
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
251 additions
and
73 deletions
+251
-73
core/src/main/java/org/b3log/solo/event/EventTypes.java
core/src/main/java/org/b3log/solo/event/EventTypes.java
+6
-1
core/src/main/java/org/b3log/solo/plugin/list/ListHandler.java
...src/main/java/org/b3log/solo/plugin/list/ListHandler.java
+101
-0
core/src/main/java/org/b3log/solo/processor/ArticleProcessor.java
.../main/java/org/b3log/solo/processor/ArticleProcessor.java
+63
-45
pom.xml
pom.xml
+2
-2
war/src/main/resources/log4j.properties
war/src/main/resources/log4j.properties
+0
-1
war/src/main/webapp/plugins/list/plugin.properties
war/src/main/webapp/plugins/list/plugin.properties
+31
-0
war/src/main/webapp/plugins/list/style.css
war/src/main/webapp/plugins/list/style.css
+47
-0
war/src/main/webapp/skins/ease/js/ease.js
war/src/main/webapp/skins/ease/js/ease.js
+1
-23
war/src/main/webapp/skins/ease/macro-comments.ftl
war/src/main/webapp/skins/ease/macro-comments.ftl
+0
-1
No files found.
core/src/main/java/org/b3log/solo/event/EventTypes.java
View file @
1b1767ca
...
...
@@ -20,7 +20,7 @@ package org.b3log.solo.event;
* Event types.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
0.0.7, Oct 17, 2012
* @version 1.
1.0.7, May 30, 2014
* @since 0.3.1
*/
public
final
class
EventTypes
{
...
...
@@ -39,6 +39,11 @@ public final class EventTypes {
* Indicates a remove article event.
*/
public
static
final
String
REMOVE_ARTICLE
=
"Remove Article"
;
/**
* Indicates a before render article event.
*/
public
static
final
String
BEFORE_RENDER_ARTICLE
=
"Before Render Article"
;
/**
* Indicates an add comment to article event.
...
...
core/src/main/java/org/b3log/solo/plugin/list/ListHandler.java
0 → 100644
View file @
1b1767ca
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
b3log
.
solo
.
plugin
.
list
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.event.AbstractEventListener
;
import
org.b3log.latke.event.Event
;
import
org.b3log.latke.event.EventException
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.solo.event.EventTypes
;
import
org.b3log.solo.model.Article
;
import
org.json.JSONObject
;
import
org.jsoup.Jsoup
;
import
org.jsoup.nodes.Document
;
import
org.jsoup.nodes.Element
;
import
org.jsoup.select.Elements
;
/**
* List (table of contents of an article) handler.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, May 30, 2014
* @since 0.6.7
*/
public
class
ListHandler
extends
AbstractEventListener
<
JSONObject
>
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ListHandler
.
class
.
getName
());
/**
* Instance.
*/
private
static
final
ListHandler
INSTANCE
=
new
ListHandler
();
@Override
public
String
getEventType
()
{
return
EventTypes
.
BEFORE_RENDER_ARTICLE
;
}
/**
* Gets the instance.
*
* @return instance
*/
public
static
ListHandler
getInstance
()
{
return
INSTANCE
;
}
@Override
public
void
action
(
final
Event
<
JSONObject
>
event
)
throws
EventException
{
final
JSONObject
data
=
event
.
getData
();
final
JSONObject
article
=
data
.
optJSONObject
(
Article
.
ARTICLE
);
String
content
=
article
.
optString
(
Article
.
ARTICLE_CONTENT
);
final
Document
doc
=
Jsoup
.
parse
(
content
);
final
StringBuilder
listBuilder
=
new
StringBuilder
();
listBuilder
.
append
(
"<link rel=\"stylesheet\" type=\"text/css\" href=\""
+
Latkes
.
getStaticPath
()
+
"/plugins/list/style.css\" />"
);
final
Elements
hs
=
doc
.
select
(
"h1, h2, h3, h4, h5"
);
listBuilder
.
append
(
"<ul class='b3-solo-list'>"
);
for
(
int
i
=
0
;
i
<
hs
.
size
();
i
++)
{
final
Element
element
=
hs
.
get
(
i
);
final
String
tagName
=
element
.
tagName
().
toLowerCase
();
final
String
text
=
element
.
text
();
final
String
id
=
"b3_solo_"
+
tagName
+
"_"
+
i
;
element
.
before
(
"<span id='"
+
id
+
"'></span>"
);
listBuilder
.
append
(
"<li class='b3-solo-list-"
).
append
(
tagName
).
append
(
"'><a href='#"
).
append
(
id
).
append
(
"'>"
).
append
(
text
).
append
(
"</a></li>"
);
}
listBuilder
.
append
(
"</ul>"
);
final
Element
body
=
doc
.
getElementsByTag
(
"body"
).
get
(
0
);
content
=
listBuilder
.
toString
()
+
body
.
html
();
article
.
put
(
Article
.
ARTICLE_CONTENT
,
content
);
}
}
core/src/main/java/org/b3log/solo/processor/ArticleProcessor.java
View file @
1b1767ca
This diff is collapsed.
Click to expand it.
pom.xml
View file @
1b1767ca
<?xml version="1.0" encoding="UTF-8"?>
<!--
Description: B3log Solo parent POM.
Version: 2.0.4.1
0, Apr 28
, 2014
Version: 2.0.4.1
1, May 31
, 2014
Author: Liang Ding
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
...
...
@@ -29,7 +29,7 @@
<properties>
<servlet.version>
2.5
</servlet.version>
<slf4j.version>
1.7.5
</slf4j.version>
<org.b3log.latke.version>
1.0.1
1
</org.b3log.latke.version>
<org.b3log.latke.version>
1.0.1
2
</org.b3log.latke.version>
<maven-gae-plugin.version>
0.9.0
</maven-gae-plugin.version>
<gae.version>
1.8.1.1
</gae.version>
...
...
war/src/main/resources/log4j.properties
View file @
1b1767ca
...
...
@@ -31,4 +31,3 @@ log4j.logger.org.b3log.solo=WARN
log4j.logger.org.b3log.latke
=
ERROR
log4j.logger.org.b3log.latke.util.freemarker.Templates
=
ERROR
war/src/main/webapp/plugins/list/plugin.properties
0 → 100644
View file @
1b1767ca
#
# Copyright (c) 2009, 2010, 2011, B3log Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Description: Table of contents generator.
# Version: 1.0.0.0, May 30, 2014
# Author: Liang Ding
#
rendererId
=
footer.ftl
author
=
<a href="http://88250.b3log.org">88250</a>
name
=
Table of Contents Generator
version
=
0.0.1
types
=
PUBLIC
classesDirPath
=
/WEB-INF/classes/
pluginClass
=
eventListenerClasses
=
org.b3log.solo.plugin.list.ListHandler
\ No newline at end of file
war/src/main/webapp/plugins/list/style.css
0 → 100644
View file @
1b1767ca
/*
* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* 403, 404, 500, article-pwd, init, login and kill-browser page style.
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.0, May 31, 2014
*/
.b3-solo-list
{
margin
:
20px
30px
;
list-style
:
none
;
}
.b3-solo-list-h1
{
}
.b3-solo-list-h2
{
margin-left
:
16px
;
}
.b3-solo-list-h3
{
margin-left
:
32px
;
}
.b3-solo-list-h4
{
margin-left
:
48px
;
}
.b3-solo-list-h5
{
margin-left
:
62px
;
}
\ No newline at end of file
war/src/main/webapp/skins/ease/js/ease.js
View file @
1b1767ca
...
...
@@ -237,20 +237,7 @@ var ease = {
scrollEvent
:
function
()
{
var
_it
=
this
;
$
(
window
).
scroll
(
function
()
{
var
y
=
$
(
window
).
scrollTop
(),
topH
=
0
;
if
(
$
(
"
#top
"
).
css
(
"
display
"
)
===
"
block
"
)
{
topH
=
$
(
"
#top
"
).
height
();
}
// header event
if
(
y
>=
_it
.
headerH
+
topH
)
{
_it
.
$nav
.
css
(
"
position
"
,
"
fixed
"
);
_it
.
$body
.
css
(
"
marginTop
"
,
"
55px
"
);
}
else
{
_it
.
$nav
.
css
(
"
position
"
,
"
inherit
"
);
_it
.
$body
.
css
(
"
marginTop
"
,
"
0
"
);
}
var
y
=
$
(
window
).
scrollTop
();
// go top icon show or hide
if
(
y
>
_it
.
headerH
)
{
...
...
@@ -293,15 +280,6 @@ var ease = {
$
(
"
.article-body
"
).
each
(
function
()
{
this
.
innerHTML
=
Util
.
replaceEmString
(
$
(
this
).
html
());
});
},
/**
* @description 纠正评论滚动位置偏差
*/
scrollToCmt
:
function
()
{
if
(
$
(
window
.
location
.
hash
).
length
==
1
)
{
$
(
window
).
scrollTop
(
$
(
window
.
location
.
hash
).
offset
().
top
-
60
);
}
}
};
...
...
war/src/main/webapp/skins/ease/macro-comments.ftl
View file @
1b1767ca
...
...
@@ -158,7 +158,6 @@
$(document).ready(function() {
page.load();
ease.scrollToCmt();
// emotions
page.replaceCommentsEm("#comments .article-body");
<#nested>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment