Widgets¶
This section describes details about widgets options and implementation.
Widgets configurator: https://userfeeds.io/apps/widgets/#/configurator/
userfeeds-links¶
Common parameters:
context
- string
- required
- values: Context
identifier specifing source of links and also destination of funds sent with link claims.
type
- string
- optional
- default: single
- values: single, list
specifies if widget should display one link at a time and rotate them or display all links in a list
limit
- number
- optional
- default: 10
Limit number of links taken from API
algorithm
- string
- optional
- default: ads
- values: Algorithms
name of the algorithm to use for links filtering/sorting
whitelist
- string
- optional
- values: Whitelisting
identifier specifing source of filtering whitelist for claims
Events¶
Lifecycle events
linksLoadStart
- when a request to ranking API is made
linksLoadSuccess
- when a request to ranking API finished successfully and returned non-empty list
linksLoadError
- when a request to ranking API failed for some reason (e.g. no network, 5xx response)
linkDisplay
- when user is shown with specific link from list (i.e. just after Links Load Success and when user or timeout changes link)
User interactions
linkOpen
- when currently displayed link is opened/clicked
widgetOpen
- when widget details is opened (i.e. modal on web, browser on Android)
JavaScript¶
Source: https://github.com/Userfeeds/JS-Widgets
Latest version is available here: https://cdn.jsdelivr.net/npm/@userfeeds/links
JS specific options
size
- string
- optional
- default: rectangle
- values: rectangle, leaderboard
Sample usage:
<userfeeds-links
context="rinkeby:0xcd73518680ab60ec2253841909d3448bc60f0665"
>
</userfeeds-links>
<script src="https://cdn.jsdelivr.net/npm/@userfeeds/links"></script>
--------------------------------
<userfeeds-links
type="single"
size="rectangle"
algorithm="internal"
context="rinkeby:0xcd73518680ab60ec2253841909d3448bc60f0665"
whitelist="rinkeby:0x123456...987"
>
</userfeeds-links>
<script src="https://cdn.jsdelivr.net/npm/@userfeeds/links"></script>
Events¶
TODO: Registering one events
Android¶
Source: https://github.com/Userfeeds/Android-Widgets
Code examples
Add widget via xml:
<io.userfeeds.widget.LinksViewPager
xmlns:userfeeds="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_links_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
userfeeds:context="ethereum:0x0406735fC1a657398941A50A0602eddf9723A6C8"/>
--------------------------
<io.userfeeds.widget.LinksViewPager
xmlns:userfeeds="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_links_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
userfeeds:algorithm="ads"
userfeeds:context="ethereum:0x0406735fC1a657398941A50A0602eddf9723A6C8"
userfeeds:whitelist="ethereum:0x123...456"/>
Or via code:
TODO
Events¶
linksLoadCancel
- when user exits the screen before links load
linkLongClick
- user long clicks the link; currently equivalent to Widget Details Open
linkSwipe
- user swipes between links; will be followed by
linkDisplay
userfeeds-button¶
This is universal button, it can be deployed anywhere to create basic or labeling claim
Options:
target
- string
- required
Specifies claim
target
value. Identifier that will be used astarget
in API responsetext
- string
- required
Button label
labels
- comma separated list of strings
- optional
Claim labels, if this is set claim type will have labels in it.
value
- number
- optional
Amount of coins to send with claim, if this is set, possible transports are reduced to value-transferable only (blockchains).
JavaScript¶
Source: https://github.com/Userfeeds/JS-Widgets
Latest version is available here: https://cdn.jsdelivr.net/npm/@userfeeds/button
Sample usage:
<userfeeds-button
text="Like"
target="http://myblog.com/"
context="rinkeby:0xcd73518680ab60ec2253841909d3448bc60f0665"
>
</userfeeds-button>
<script src="https://cdn.jsdelivr.net/npm/@userfeeds/button"></script>
-----------------------
<userfeeds-button
text="Like"
labels="like"
target="http://myblog.com/"
context="rinkeby:0xcd73518680ab60ec2253841909d3448bc60f0665"
>
</userfeeds-button>
<script src="https://cdn.jsdelivr.net/npm/@userfeeds/button"></script>
-----------------------
<userfeeds-button
text="This is a Cat"
labels="cat"
target="http://myphotos.com/some-photo"
context="rinkeby:0xcd73518680ab60ec2253841909d3448bc60f0665"
>
</userfeeds-button>
<script src="https://cdn.jsdelivr.net/npm/@userfeeds/button"></script>
-----------------------
<userfeeds-button
text="Upvote"
labels="up,good,positive"
target="http://myphotos.com/some-photo"
context="rinkeby:0xcd73518680ab60ec2253841909d3448bc60f0665"
>
</userfeeds-button>
<script src="https://cdn.jsdelivr.net/npm/@userfeeds/button"></script>
-----------------------
<userfeeds-button
text="Post"
value="0.5"
target="http://myphotos.com/some-photo"
context="rinkeby:0xcd73518680ab60ec2253841909d3448bc60f0665"
>
</userfeeds-button>
<script src="https://cdn.jsdelivr.net/npm/@userfeeds/button"></script>
Android¶
Source: https://github.com/Userfeeds/Android-Widgets
Code examples
Add widget via xml:
<io.userfeeds.widget.ButtonView
xmlns:userfeeds="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_button_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Like"
userfeeds:target="http://someurl.url/"
userfeeds:labels="like"
userfeeds:context="ethereum:0x0406735fC1a657398941A50A0602eddf9723A6C8"/>
-----------------------
<io.userfeeds.widget.ButtonView
xmlns:userfeeds="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_button_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is a Cat"
userfeeds:target="http://someurl.url/"
userfeeds:labels="cat"
userfeeds:context="ethereum:0x0406735fC1a657398941A50A0602eddf9723A6C8"/>
-----------------------
<io.userfeeds.widgets.ButtonView
xmlns:userfeeds="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_button_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Upvote"
userfeeds:target="http://someurl.url/"
userfeeds:labels="up,good,positive"
userfeeds:context="ethereum:0x0406735fC1a657398941A50A0602eddf9723A6C8"/>
Or via code:
TODO