Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 136 lines (100 sloc) 3.837 kb
649f24a7 » iko
2012-02-13 update readme
1 # flowdock-text
537ce28b » bcherry
2010-10-22 readme
2
8c590606 » livedo
2012-02-14 Spelling
3 Flowdock-text is a javascript utility for extracting and linkifying hashtags and URLs in Flowdock. It is built upon Twitter's [twitter-text-js](https://github.com/twitter/twitter-text-js). Some twitter-text's functionality has been removed or altered.
2e53aff9 » ded
2011-07-11 make note on npm installation
4
649f24a7 » iko
2012-02-13 update readme
5 ## Usage
6 ### Extraction
2e53aff9 » ded
2011-07-11 make note on npm installation
7
649f24a7 » iko
2012-02-13 update readme
8 Hashtag extraction
2e53aff9 » ded
2011-07-11 make note on npm installation
9
aa8ccabc » iko
2012-02-13 reformat readme
10 ```javascript
11 FlowdockText.extractHashtags("hello #world");
12 [ 'world' ]
13 FlowdockText.extractHashtagsWithIndices("hello #world");
e0461abc » iko
2012-02-13 change returned key simply to 'tag' ...
14 [ { tag: 'world', indices: [ 6, 12 ] } ]
aa8ccabc » iko
2012-02-13 reformat readme
15 ```
2e53aff9 » ded
2011-07-11 make note on npm installation
16
649f24a7 » iko
2012-02-13 update readme
17 Usertag extraction
537ce28b » bcherry
2010-10-22 readme
18
aa8ccabc » iko
2012-02-13 reformat readme
19 ```javascript
20 FlowdockText.extractMentions("hello @Username");
21 [ '@Username' ]
22 FlowdockText.extractMentionsWithIndices("hello @Username");
e0461abc » iko
2012-02-13 change returned key simply to 'tag' ...
23 [ { tag: '@Username', indices: [ 6, 15 ] } ]
aa8ccabc » iko
2012-02-13 reformat readme
24 ```
537ce28b » bcherry
2010-10-22 readme
25
8c590606 » livedo
2012-02-14 Spelling
26 URL extraction
ff44c3f4 » iko
2012-02-13 fix readme GFM
27
aa8ccabc » iko
2012-02-13 reformat readme
28 ```javascript
29 FlowdockText.extractUrls("hello http://www.example.com");
30 [ 'http://www.example.com' ]
31 FlowdockText.extractUrlsWithIndices("hello http://www.example.com");
32 [ { url: 'http://www.example.com', indices: [ 6, 28 ] } ]
33 ```
537ce28b » bcherry
2010-10-22 readme
34
a88fe3b0 » livedo
2012-02-14 Sectioning
35 ### Linkification
36
37 ```javascript
38 FlowdockText.autoLink("hello @Username #greets");
39 'hello <a title="Search @Username" class="app-tag-link" href="#flowser/all/@Username">@Username</a> <a href="#flowser/all/greets" title="#greets" class="app-tag-link">#greets</a>'
40 ```
41
42 ### Parsing all tags from new messages
43
76743a1f » iko
2012-02-15 readme typo fix
44 If you need to replicate the functionality that Flowdock uses to parse tags from new messages, you can use `parseTags`.
a88fe3b0 » livedo
2012-02-14 Sectioning
45
ff44c3f4 » iko
2012-02-13 fix readme GFM
46
aa8ccabc » iko
2012-02-13 reformat readme
47 ```javascript
ae1e00a1 » iko
2012-02-15 rename getTagsFromMessage to parseTags
48 FlowdockText.parseTags("@anyone seen this: http://www.example.com #cool");
aa8ccabc » iko
2012-02-13 reformat readme
49 [ 'cool', ':url', ':user:everyone' ]
50 ```
537ce28b » bcherry
2010-10-22 readme
51
649f24a7 » iko
2012-02-13 update readme
52 Parse and process tags from a message with optional array of user-objects
ff44c3f4 » iko
2012-02-13 fix readme GFM
53
aa8ccabc » iko
2012-02-13 reformat readme
54 ```javascript
55 var users = [
56 {nick: "Username", id: 1, disabled: false},
57 {nick: "Other", id: 2, disabled: false}
58 ];
ae1e00a1 » iko
2012-02-15 rename getTagsFromMessage to parseTags
59 FlowdockText.parseTags("@anyone seen this: http://www.example.com #cool", users);
aa8ccabc » iko
2012-02-13 reformat readme
60 [ 'cool', ':url', ':user:everyone', ':unread:1', ':unread:2' ]
61 ```
537ce28b » bcherry
2010-10-22 readme
62
649f24a7 » iko
2012-02-13 update readme
63 Parse and process tags from a message with optional array of user-objects and me-object (which excludes :unread:my-id tag from the results)
ff44c3f4 » iko
2012-02-13 fix readme GFM
64
aa8ccabc » iko
2012-02-13 reformat readme
65 ```javascript
66 var users = [
67 {nick: "Username", id: 1, disabled: false},
68 {nick: "Other", id: 2, disabled: false}
69 ];
70 var me = users[1];
ae1e00a1 » iko
2012-02-15 rename getTagsFromMessage to parseTags
71 FlowdockText.parseTags("@anyone seen this: http://www.example.com #cool", users, me);
aa8ccabc » iko
2012-02-13 reformat readme
72 [ 'cool', ':url', ':user:everyone', ':unread:1' ]
73 ```
537ce28b » bcherry
2010-10-22 readme
74
da8f3350 » iko
2012-02-15 one more example to readme
75 Tagging a single user
480815d2 » iko
2012-02-13 one more usage example to readme
76
77 ```javascript
78 var users = [
79 {nick: "Username", id: 1, disabled: false},
80 {nick: "Other", id: 2, disabled: false}
81 ];
82 var me = users[1];
ae1e00a1 » iko
2012-02-15 rename getTagsFromMessage to parseTags
83 FlowdockText.parseTags("@Username, what do you think?", users, me);
480815d2 » iko
2012-02-13 one more usage example to readme
84 [ ':user:1', ':unread:1' ]
85 ```
86
da8f3350 » iko
2012-02-15 one more example to readme
87 Mentioning a single user
88
89 ```javascript
90 var users = [
91 {nick: "Username", id: 1, disabled: false},
92 {nick: "Other", id: 2, disabled: false}
93 ];
94 var me = users[1];
95 FlowdockText.parseTags("Username, what do you think?", users, me);
96 [ ':highlight:1', ':unread:1' ]
97 ```
98
649f24a7 » iko
2012-02-13 update readme
99 ## NPM
537ce28b » bcherry
2010-10-22 readme
100
649f24a7 » iko
2012-02-13 update readme
101 Install with: `npm install flowdock-text`
ff44c3f4 » iko
2012-02-13 fix readme GFM
102
aa8ccabc » iko
2012-02-13 reformat readme
103 ```javascript
104 var FlowdockText = require("flowdock-text");
105 FlowdockText.extractUrlsWithIndices("cool http://www.example.com");
106 [ { url: 'http://www.example.com', indices: [ 6, 28 ] } ]
107 ```
e8b14565 » keitaf
2012-01-03 Update README with a detailed note about URL extraction/auto-link.
108
649f24a7 » iko
2012-02-13 update readme
109 ## Tests
110 Tests can be run in browsers or with node.js
e8b14565 » keitaf
2012-01-03 Update README with a detailed note about URL extraction/auto-link.
111
649f24a7 » iko
2012-02-13 update readme
112 To run the tests in your default browser:
537ce28b » bcherry
2010-10-22 readme
113
114 rake test
115
649f24a7 » iko
2012-02-13 update readme
116 To run the tests with node.js
537ce28b » bcherry
2010-10-22 readme
117
649f24a7 » iko
2012-02-13 update readme
118 rake test_node
27e2b44a » bcherry
2011-04-29 update license
119
120 ## Copyright and License
121
122 Copyright 2011 Twitter, Inc.
619e316a » iko
2012-02-15 format readme
123
f32e461d » iko
2012-02-14 copyright updates
124 Copyright 2011 Flowdock Ltd
27e2b44a » bcherry
2011-04-29 update license
125
126 Licensed under the Apache License, Version 2.0 (the "License");
127 you may not use this work except in compliance with the License.
128 You may obtain a copy of the License in the LICENSE file, or at:
129
130 http://www.apache.org/licenses/LICENSE-2.0
131
132 Unless required by applicable law or agreed to in writing, software
133 distributed under the License is distributed on an "AS IS" BASIS,
134 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135 See the License for the specific language governing permissions and
e8b14565 » keitaf
2012-01-03 Update README with a detailed note about URL extraction/auto-link.
136 limitations under the License.
Something went wrong with that request. Please try again.