Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Danny Froberg
steempress_amn
Commits
35667492
Commit
35667492
authored
Aug 10, 2018
by
Martin Lees
Browse files
First version of the comment feed working
parent
9e424407
Changes
3
Hide whitespace changes
Inline
Side-by-side
public/class-steempress_sp-public.php
View file @
35667492
...
...
@@ -110,11 +110,9 @@ class Steempress_sp_Public {
$permlink
=
get_post_meta
(
$id
,
"steempress_sp_permlink"
);
$tag
=
get_post_meta
(
$id
,
"steempress_sp_tag"
);
$payout
=
""
;
$data
=
""
;
$comments
=
""
;
if
(
sizeof
(
$username
)
==
1
and
sizeof
(
$permlink
)
==
1
and
sizeof
(
$tag
)
==
1
)
{
...
...
@@ -131,10 +129,10 @@ class Steempress_sp_Public {
$payout
=
"<div id='steempress_sp_price'>0.000$</div>"
;
// comment zone
//echo ($this->
steempress_sp_
steem_
comments
($id, $username, $permlink))
;
$comments
=
"<div id='
steempress_sp_comments
'></div>"
;
}
return
$content
.
$data
.
$payout
;
return
$content
.
$data
.
$payout
.
$comments
;
}
...
...
public/css/steempress_sp-public.css
View file @
35667492
...
...
@@ -6,4 +6,52 @@
#steempress_sp_price
{
text-align
:
right
;
}
\ No newline at end of file
}
steempress_sp_cmmnt
img
{
border
:
0
;
max-width
:
100%
;
}
/* page layout structure */
#w
{
display
:
block
;
width
:
700px
;
margin
:
0
auto
;
padding-top
:
35px
;
}
#steempress_sp_comment_container
{
display
:
block
;
width
:
100%
;
font-size
:
62.5%
;
line-height
:
1
;
font-family
:
Arial
,
sans-serif
;
}
.steempress_sp_comment_text
{
font-family
:
Arial
,
Geneva
,
Verdana
,
sans-serif
;
font-size
:
1.3em
;
line-height
:
1.42em
;
margin-bottom
:
12px
;
font-weight
:
normal
;
color
:
#656565
;
}
/* steempress_sp_comments area */
#steempress_sp_comments
{
display
:
block
;
}
#steempress_sp_comments
.steempress_sp_cmmnt
,
ul
.steempress_sp_cmmnt
,
ul
ul
.steempress_sp_cmmnt
{
display
:
block
;
position
:
relative
;
padding-left
:
65px
;
border-top
:
1px
solid
#ddd
;
}
#steempress_sp_comments
.steempress_sp_cmmnt
.avatar
{
position
:
absolute
;
top
:
8px
;
left
:
0
;
}
#steempress_sp_comments
.steempress_sp_cmmnt
.avatar
img
{
-webkit-border-radius
:
3px
;
-moz-border-radius
:
3px
;
border-radius
:
3px
;
-webkit-box-shadow
:
1px
1px
2px
rgba
(
0
,
0
,
0
,
0.44
);
-moz-box-shadow
:
1px
1px
2px
rgba
(
0
,
0
,
0
,
0.44
);
box-shadow
:
1px
1px
2px
rgba
(
0
,
0
,
0
,
0.44
);
-webkit-transition
:
all
0.4s
linear
;
-moz-transition
:
all
0.4s
linear
;
-ms-transition
:
all
0.4s
linear
;
-o-transition
:
all
0.4s
linear
;
transition
:
all
0.4s
linear
;
}
#steempress_sp_comments
.steempress_sp_cmmnt
.avatar
a
:hover
img
{
opacity
:
0.77
;
}
#steempress_sp_comments
.steempress_sp_cmmnt
.steempress_sp_cmmnt-content
{
padding
:
0px
3px
;
padding-bottom
:
12px
;
padding-top
:
8px
;
}
#steempress_sp_comments
.steempress_sp_cmmnt
.steempress_sp_cmmnt-content
header
{
font-size
:
1.3em
;
display
:
block
;
margin-bottom
:
8px
;
}
#steempress_sp_comments
.steempress_sp_cmmnt
.steempress_sp_cmmnt-content
header
.pubdate
{
color
:
#777
;
}
#steempress_sp_comments
.steempress_sp_cmmnt
.steempress_sp_cmmnt-content
header
.userlink
{
font-weight
:
bold
;
}
#steempress_sp_comments
.steempress_sp_cmmnt
.replies
{
margin-bottom
:
7px
;
}
public/js/steempress_sp-public.js
View file @
35667492
...
...
@@ -31,40 +31,110 @@
*/
$
(
window
).
load
(
function
()
{
function
get_all_comments
(
author
,
permlink
,
tag
,
callback
)
{
steem
.
api
.
getState
(
tag
+
"
/@
"
+
author
+
"
/
"
+
permlink
,
function
(
err
,
post
)
{
if
(
err
)
return
resolve
({
error
:
err
});
const
username
=
$
(
"
#steempress_sp_username
"
)[
0
].
innerText
;
const
permlink
=
$
(
"
#steempress_sp_permlink
"
)[
0
].
innerText
;
const
tag
=
$
(
"
#steempress_sp_tag
"
)[
0
].
innerText
;
if
(
post
[
'
root_permlink
'
]
===
""
&&
post
[
'
root_author
'
]
===
""
)
return
resolve
({
error
:
"
content not found
"
});
var
comment_list
=
post
.
content
;
var
comments_ordered
=
[];
var
author_list
=
new
Set
([]);
// will be used later to query the blockchain for user avatars
for
(
const
comment_id
in
comment_list
)
{
// grab value
steem
.
api
.
getContent
(
username
,
permlink
,
function
(
err
,
response
)
{
if
(
!
err
)
{
var
comment
=
comment_list
[
comment_id
];
if
(
response
.
total_payout_value
!==
"
0.000 SBD
"
)
$
(
"
#steempress_sp_price
"
)[
0
].
innerHTML
=
response
.
total_payout_value
.
replace
(
"
SBD
"
,
"
$
"
)
else
$
(
"
#steempress_sp_price
"
)[
0
].
innerHTML
=
response
.
pending_payout_value
.
replace
(
"
SBD
"
,
"
$
"
)
if
(
comment
.
depth
!==
0
)
continue
;
comments_ordered
.
push
(
get_replies
(
comment
,
comment_list
,
author_list
));
}
return
callback
(
comments_ordered
);
});
}
function
get_replies
(
comment
,
comment_list
,
author_list
)
{
author_list
.
add
(
comment
.
author
);
for
(
var
i
=
0
;
i
<
comment
.
replies
.
length
;
i
++
)
{
var
reply
=
comment_list
[
comment
.
replies
[
i
]];
if
(
reply
.
total_payout_value
!==
"
0.000 SBD
"
)
reply
.
payout
=
reply
.
total_payout_value
.
replace
(
"
SBD
"
,
""
);
else
reply
.
payout
=
reply
.
pending_payout_value
.
replace
(
"
SBD
"
,
""
);
reply
.
payout
=
(
Math
.
floor
(
parseFloat
(
reply
.
payout
)
*
100
)
/
100
);
reply
.
payout
=
reply
.
payout
.
toString
()
+
"
$
"
;
comment
.
replies
[
i
]
=
get_replies
(
reply
,
comment_list
,
author_list
);
}
return
comment
;
}
function
generate_comment_string
(
comments
)
{
var
str
=
""
;
for
(
var
i
=
0
;
i
<
comments
.
length
;
i
++
)
{
str
+=
"
<li class=
\"
steempress_sp_cmmnt
\"
>
\n
"
+
"
<div class=
\"
avatar
\"
><img src=
\"
https://steemitimages.com/u/
"
+
comments
[
i
].
author
+
"
/avatar
\"
width=
\"
55
\"
height=
\"
55
\"
alt=
\"
"
+
comments
[
i
].
author
+
"
's avatar
\"
></div>
\n
"
+
"
<div class=
\"
steempress_sp_cmmnt-content
\"
>
\n
"
+
"
<header><a href=
\"
https://steemit.com/@
"
+
comments
[
i
].
author
+
"
\"
class=
\"
userlink
\"
>
"
+
comments
[
i
].
author
+
"
</a> - <span class=
\"
pubdate
\"
>posted 6 days ago</span>
"
+
comments
[
i
].
payout
+
"
</header>
\n
"
+
"
<p class=
\"
steempress_sp_comment_text
\"
>
"
+
comments
[
i
].
body
+
"
</p>
\n
"
+
"
</div>
\n
"
if
(
comments
[
i
].
replies
.
length
!==
0
)
{
str
+=
"
<ul class=
\"
replies
\"
>
"
;
str
+=
generate_comment_string
(
comments
[
i
].
replies
);
str
+=
"
</ul>
"
;
}
str
+=
"
</li>
"
}
return
str
;
steem
.
api
.
getState
(
"
steempress/@petanque/testcomments-xylmwuwi6p
"
,
function
(
err
,
result
)
{
console
.
log
(
err
,
result
);
});
}
function
generate_replies_string
(
comment
)
{
}
$
(
window
).
load
(
function
()
{
const
username
=
$
(
"
#steempress_sp_username
"
)[
0
].
innerText
;
const
permlink
=
$
(
"
#steempress_sp_permlink
"
)[
0
].
innerText
;
const
tag
=
$
(
"
#steempress_sp_tag
"
)[
0
].
innerText
;
get_all_comments
(
username
,
permlink
,
tag
,
function
(
result
)
{
var
payout
=
""
;
if
(
result
[
0
].
total_payout_value
!==
"
0.000 SBD
"
)
payout
=
result
[
0
].
total_payout_value
.
replace
(
"
SBD
"
,
""
);
else
payout
=
result
[
0
].
pending_payout_value
.
replace
(
"
SBD
"
,
""
);
payout
=
(
Math
.
floor
(
parseFloat
(
payout
)
*
100
)
/
100
);
payout
=
payout
.
toString
()
+
"
$
"
;
$
(
"
#steempress_sp_price
"
)[
0
].
innerHTML
=
payout
;
var
comment_str
=
"
<div id=
\"
steempress_sp_comment_container
\"
><ul id=
\"
steempress_sp_comments
\"
>
"
;
comment_str
+=
generate_comment_string
(
result
[
0
].
replies
);
comment_str
+=
"
</ul></div>
"
;
$
(
"
#steempress_sp_comments
"
)[
0
].
innerHTML
=
comment_str
;
});
})
})(
jQuery
);
...
...
@@ -72,3 +142,8 @@
;
/*
*/
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