Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
diaspora
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
diasporg
diaspora
Commits
1ccf9651
Commit
1ccf9651
authored
Oct 19, 2011
by
Ilya Zhitomirskiy
Committed by
danielgrippi
Oct 24, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
publisher lib, prefill, open, still need to do public first message for new users
parent
ee749488
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
125 additions
and
15 deletions
+125
-15
app/helpers/interim_stream_hackiness_helper.rb
app/helpers/interim_stream_hackiness_helper.rb
+10
-2
app/views/shared/_publisher.html.haml
app/views/shared/_publisher.html.haml
+7
-0
lib/publisher.rb
lib/publisher.rb
+2
-2
lib/stream/aspect.rb
lib/stream/aspect.rb
+28
-0
lib/stream/base.rb
lib/stream/base.rb
+1
-5
lib/stream/tag.rb
lib/stream/tag.rb
+4
-4
spec/lib/publisher_spec.rb
spec/lib/publisher_spec.rb
+2
-2
spec/lib/stream/aspect_spec.rb
spec/lib/stream/aspect_spec.rb
+63
-0
spec/lib/stream/tag_spec.rb
spec/lib/stream/tag_spec.rb
+8
-0
No files found.
app/helpers/interim_stream_hackiness_helper.rb
View file @
1ccf9651
...
@@ -14,7 +14,7 @@ module InterimStreamHackinessHelper
...
@@ -14,7 +14,7 @@ module InterimStreamHackinessHelper
if
params
[
:prefill
].
present?
if
params
[
:prefill
].
present?
params
[
:prefill
]
params
[
:prefill
]
elsif
defined?
(
@stream
)
elsif
defined?
(
@stream
)
@stream
.
publisher
_prefill_text
@stream
.
publisher
.
prefill
else
else
nil
nil
end
end
...
@@ -24,7 +24,7 @@ module InterimStreamHackinessHelper
...
@@ -24,7 +24,7 @@ module InterimStreamHackinessHelper
if
defined?
(
@stream
)
&&
params
[
:controller
]
==
'multis'
if
defined?
(
@stream
)
&&
params
[
:controller
]
==
'multis'
@stream
.
post_from_group
(
post
)
@stream
.
post_from_group
(
post
)
else
else
[]
[]
end
end
end
end
...
@@ -35,4 +35,12 @@ module InterimStreamHackinessHelper
...
@@ -35,4 +35,12 @@ module InterimStreamHackinessHelper
def
stream_settings_link
(
post
)
def
stream_settings_link
(
post
)
link_to
""
,
"
#{
edit_user_path
}
#stream-preferences"
link_to
""
,
"
#{
edit_user_path
}
#stream-preferences"
end
end
def
publisher_open
if
defined?
(
@stream
)
@stream
.
publisher
.
open?
else
false
end
end
end
end
app/views/shared/_publisher.html.haml
View file @
1ccf9651
...
@@ -9,6 +9,13 @@
...
@@ -9,6 +9,13 @@
$
(
"
.public_icon
"
).
tipsy
({
trigger
:
'
hover
'
,
gravity
:
'
n
'
});
$
(
"
.public_icon
"
).
tipsy
({
trigger
:
'
hover
'
,
gravity
:
'
n
'
});
});
});
-
if
publisher_open
:javascript
$
(
document
).
ready
(
function
()
{
Publisher
.
open
();
});
#publisher
.closed
{
:class
=>
((
aspect
==
:profile
)?
'mention_popup'
:
nil
)}
#publisher
.closed
{
:class
=>
((
aspect
==
:profile
)?
'mention_popup'
:
nil
)}
.content_creation
.content_creation
=
form_for
(
StatusMessage
.
new
,
:remote
=>
remote?
,
:html
=>
{
"data-type"
=>
"json"
})
do
|
status
|
=
form_for
(
StatusMessage
.
new
,
:remote
=>
remote?
,
:html
=>
{
"data-type"
=>
"json"
})
do
|
status
|
...
...
lib/publisher.rb
View file @
1ccf9651
class
Publisher
class
Publisher
attr_accessor
:user
,
:open
,
:prefill
_text
,
:public
attr_accessor
:user
,
:open
,
:prefill
,
:public
def
initialize
(
user
,
opts
=
{})
def
initialize
(
user
,
opts
=
{})
self
.
user
=
user
self
.
user
=
user
self
.
open
=
(
opts
[
:open
]
==
true
)?
true
:
false
self
.
open
=
(
opts
[
:open
]
==
true
)?
true
:
false
self
.
prefill
_text
=
opts
[
:prefill_text
]
self
.
prefill
=
opts
[
:prefill
]
self
.
public
=
(
opts
[
:public
]
==
true
)?
true
:
false
self
.
public
=
(
opts
[
:public
]
==
true
)?
true
:
false
end
end
...
...
lib/stream/aspect.rb
View file @
1ccf9651
...
@@ -126,4 +126,32 @@ class Stream::Aspect < Stream::Base
...
@@ -126,4 +126,32 @@ class Stream::Aspect < Stream::Base
def
can_comment?
(
post
)
def
can_comment?
(
post
)
true
true
end
end
def
publisher
if
welcome?
@publisher
||=
Publisher
.
new
(
self
.
user
,
:open
=>
true
,
:prefill
=>
publisher_prefill
,
:public
=>
true
)
else
super
end
end
private
# Generates the prefill for the publisher
#
# @return [String]
def
publisher_prefill
prefill
=
"Hi, I'm #newhere."
if
self
.
user
.
followed_tags
.
size
>
0
tag_string
=
self
.
user
.
followed_tags
.
map
{
|
t
|
"#
#{
t
.
name
}
"
}.
join
(
", "
)
prefill
<<
"I like
#{
tag_string
}
."
end
prefill
end
def
welcome?
self
.
user
.
getting_started
end
end
end
lib/stream/base.rb
View file @
1ccf9651
...
@@ -44,11 +44,6 @@ class Stream::Base
...
@@ -44,11 +44,6 @@ class Stream::Base
[]
[]
end
end
# @return [String]
def
publisher_prefill_text
''
end
# @return [ActiveRecord::Association<Person>] AR association of people within stream's given aspects
# @return [ActiveRecord::Association<Person>] AR association of people within stream's given aspects
def
people
def
people
people_ids
=
posts
.
map
{
|
x
|
x
.
author_id
}
people_ids
=
posts
.
map
{
|
x
|
x
.
author_id
}
...
@@ -107,6 +102,7 @@ class Stream::Base
...
@@ -107,6 +102,7 @@ class Stream::Base
@order
||=
'created_at'
@order
||=
'created_at'
end
end
# @return [Publisher]
def
publisher
def
publisher
@publisher
||=
Publisher
.
new
(
self
.
user
)
@publisher
||=
Publisher
.
new
(
self
.
user
)
end
end
...
...
lib/stream/tag.rb
View file @
1ccf9651
...
@@ -35,14 +35,14 @@ class Stream::Tag < Stream::Base
...
@@ -35,14 +35,14 @@ class Stream::Tag < Stream::Base
@posts
||=
construct_post_query
@posts
||=
construct_post_query
end
end
def
publisher_prefill_text
display_tag_name
+
' '
end
def
tag_name
=
(
tag_name
)
def
tag_name
=
(
tag_name
)
@tag_name
=
tag_name
.
downcase
.
gsub
(
'#'
,
''
)
@tag_name
=
tag_name
.
downcase
.
gsub
(
'#'
,
''
)
end
end
def
publisher
@publisher
||=
Publisher
.
new
(
self
.
user
,
:prefill
=>
"
#{
display_tag_name
}
"
)
end
private
private
def
construct_post_query
def
construct_post_query
...
...
spec/lib/publisher_spec.rb
View file @
1ccf9651
...
@@ -21,11 +21,11 @@ describe Publisher do
...
@@ -21,11 +21,11 @@ describe Publisher do
describe
"#prefill"
do
describe
"#prefill"
do
it
'defaults to nothing'
do
it
'defaults to nothing'
do
@publisher
.
prefill
_text
.
should
be_blank
@publisher
.
prefill
.
should
be_blank
end
end
it
'is settable'
do
it
'is settable'
do
Publisher
.
new
(
alice
,
:prefill
_text
=>
"party!"
).
prefill_text
.
should
==
"party!"
Publisher
.
new
(
alice
,
:prefill
=>
"party!"
).
prefill
.
should
==
"party!"
end
end
end
end
...
...
spec/lib/stream/aspect_spec.rb
View file @
1ccf9651
...
@@ -172,4 +172,67 @@ describe Stream::Aspect do
...
@@ -172,4 +172,67 @@ describe Stream::Aspect do
end
end
it_should_behave_like
'it is a stream'
it_should_behave_like
'it is a stream'
end
end
describe
"#publisher"
do
before
do
@stream
=
Stream
::
Aspect
.
new
(
alice
,
alice
.
aspects
.
map
(
&
:id
))
@stream
.
stub
(
:welcome?
).
and_return
(
false
)
end
it
'does not use prefill text by default'
do
@stream
.
should_not_receive
(
:publisher_prefill
)
@stream
.
publisher
end
it
'checks welcome?'
do
@stream
.
should_receive
(
:welcome?
).
and_return
(
true
)
@stream
.
publisher
end
it
'creates a welcome publisher for new user'
do
@stream
.
stub
(
:welcome?
).
and_return
(
true
)
@stream
.
should_receive
(
:publisher_prefill
).
and_return
(
"abc"
)
Publisher
.
should_receive
(
:new
).
with
(
alice
,
hash_including
(
:open
=>
true
,
:prefill
=>
"abc"
,
:public
=>
true
))
@stream
.
publisher
end
it
'creates a default publisher for returning users'
do
Publisher
.
should_receive
(
:new
).
with
(
alice
)
@stream
.
publisher
end
end
describe
"#publisher_prefill"
do
before
do
@tag
=
ActsAsTaggableOn
::
Tag
.
find_or_create_by_name
(
"cats"
)
@tag_following
=
alice
.
tag_followings
.
create
(
:tag_id
=>
@tag
.
id
)
@stream
=
Stream
::
Aspect
.
new
(
alice
,
alice
.
aspects
.
map
(
&
:id
))
end
it
'returns includes new user hashtag'
do
@stream
.
send
(
:publisher_prefill
).
include?
(
"#newhere"
).
should
be_true
end
it
'includes followed hashtags'
do
@stream
.
send
(
:publisher_prefill
).
include?
(
"#cats"
).
should
be_true
end
end
describe
"#welcome?"
do
it
'returns true if user is getting started'
do
alice
.
getting_started
=
true
Stream
::
Aspect
.
new
(
alice
,
alice
.
aspects
.
map
(
&
:id
)).
send
(
:welcome?
).
should
be_true
end
it
'returns false if user is getting started'
do
alice
.
getting_started
=
false
Stream
::
Aspect
.
new
(
alice
,
alice
.
aspects
.
map
(
&
:id
)).
send
(
:welcome?
).
should
be_false
end
end
end
end
spec/lib/stream/tag_spec.rb
View file @
1ccf9651
...
@@ -91,4 +91,12 @@ describe Stream::Tag do
...
@@ -91,4 +91,12 @@ describe Stream::Tag do
stream
.
tag_name
.
should
==
'what'
stream
.
tag_name
.
should
==
'what'
end
end
end
end
describe
"#publisher"
do
it
'creates a publisher with the tag prefill'
do
Publisher
.
should_receive
(
:new
).
with
(
anything
(),
hash_including
(
:prefill
=>
"#what "
))
@stream
=
Stream
::
Tag
.
new
(
alice
,
"what"
)
@stream
.
publisher
end
end
end
end
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