+-+-+ +-+ +-+-+-+-+
|G|O| |4| |H|I|V|E|
+-+-+ +-+ +-+-+-+-+

 --- A GOPHER-LIKE INTERFACE FOR HIVE BLOCKCHAIN ---

SteemThink-Use angular & steem API create steem blockchain-based sites

BY: @steemthinkcom | CREATED: March 5, 2018, 3:21 p.m. | VOTES: 10 | PAYOUT: $45.27 | [ VOTE ]

New Projects

[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1520261339/orte1nu6tgrmv4svoxmj.jpg]

> As can be seen from the picture, the page has been from the block chain to get the latest articles under the utopian-io directory.
Below I will share with you how this page is completed, only for the angular and steem api to share.

Use steem API to get the latest data in the utopian-io directory

var app = angular.module('myApp', []);
        app.controller('siteCtrl', function($scope, $http) {
            $http({
                method: 'GET',
                url: 'https://api.steemjs.com/get_discussions_by_created?query={"tag":"utopian-io", "limit": "10"}'
            }).then(function successCallback(response) {
                $scope.lists = response.data;
            }, function errorCallback(response) {
            });
        });

Use angular's http service to get data from the blockchain,the Request URL is

https://api.steemjs.com/get_discussions_by_created?query={"tag":"utopian-io", "limit": "10"}'

the method is GET

Use angular Create a module and Add controller

var app = angular.module('myApp', []);
app.controller('siteCtrl', function($scope, $http)

Format the reputation from json , use 2 part code

for (i=0; i<$scope.lists.length; i++ ) {
                    var author_reputation = this.change($scope.lists[i].author_reputation);
                    $scope.lists[i].author_reputation = author_reputation;
                }

and

function change(reputation){
            if (reputation == null) return reputation;
            reputation = parseInt(reputation);
            let rep = String(reputation);
            const neg = rep.charAt(0) === "-";
            rep = neg ? rep.substring(1) : rep;
            const str = rep;
            const leadingDigits = parseInt(str.substring(0, 4));
            const log = Math.log(leadingDigits) / Math.log(10);
            const n = str.length - 1;
            let out = n + (log - parseInt(log));
            if (isNaN(out)) out = 0;
            out = Math.max(out - 9, 0);
            out = (neg ? -1 : 1) * out;
            out = out * 9 + 25;
            out = parseInt(out);
            return out;
        };

Because the field value obtained by the official api is a string that needs to be formatted for normal display.
Here need to thank @stoodkev, For the format gave me a great help.
this article is for your reference:Steem.Js for dummies #4: Users reputation

After the data is processed, we display it using angular ng-repeat














                                     {{ x.title }} 







{{ x.body|limitTo:150}} ...






this is tag






                                        {{ x.author }}

                                    {{x.author_reputation}}

                                    {{ x.created | date : 'yyyy-MM-dd HH:mm:ss' }}








{{ x.pending_payout_value | limitTo:6 }}Earn

{{ x.children }}Answers

{{x.net_votes}}Upvote












Homepage File :https://github.com/steemthink/steemthink/blob/master/html/index.html







SteemThink - You Ask - We Answer - Share Knowledge




































Home

About us
























                        Login













                             ASK A QUESTION









Questions

                                18




Answer

                                12








©2018
        Terms & Privacy














                All Questions














New

Trending

Hot






















                                     {{ x.title }} 







{{ x.body|limitTo:150}} ...






this is tag






                                        {{ x.author }}

                                    {{x.author_reputation}}

                                    {{ x.created | date : 'yyyy-MM-dd HH:mm:ss' }}








{{ x.pending_payout_value | limitTo:6 }}Earn

{{ x.children }}Answers

{{x.net_votes}}Upvote

































Witness



SteemThink is now the first Q&A platform driven STEEM Witness!

                         Vote 



Github



SteemThink is an open source project, if you are interested in our project, please visit github download.

                         Download 

















        var app = angular.module('myApp', []);
        app.controller('siteCtrl', function($scope, $http) {
            $http({
                method: 'GET',
                url: 'https://api.steemjs.com/get_discussions_by_created?query={"tag":"utopian-io", "limit": "10"}'
            }).then(function successCallback(response) {
                $scope.lists = response.data;
                for (i=0; i<$scope.lists.length; i++ ) {
                    var author_reputation = this.change($scope.lists[i].author_reputation);
                    $scope.lists[i].author_reputation = author_reputation;
                }
            }, function errorCallback(response) {
            });
        });

        function change(reputation){
            if (reputation == null) return reputation;
            reputation = parseInt(reputation);
            let rep = String(reputation);
            const neg = rep.charAt(0) === "-";
            rep = neg ? rep.substring(1) : rep;
            const str = rep;
            const leadingDigits = parseInt(str.substring(0, 4));
            const log = Math.log(leadingDigits) / Math.log(10);
            const n = str.length - 1;
            let out = n + (log - parseInt(log));
            if (isNaN(out)) out = 0;
            out = Math.max(out - 9, 0);
            out = (neg ? -1 : 1) * out;
            out = out * 9 + 25;
            out = parseInt(out);
            return out;
        };




Posted on Utopian.io - Rewarding Open Source Contributors

TAGS: [ #utopian-io ] [ #steemthink ] [ #steem-dev ] [ #steemit ] [ #dev ]

Replies

@steemthinkcom | March 6, 2018, 2:40 p.m. | Votes: 1 | [ VOTE ]

Today I completed the production of 80% of the content page, but there are still some problems in the body field resolution. When I finish, I will continue to share with you.
The content page uses the angular routing function & passing parameters through the url.
Please look forward to my share, thanks again.

@eastmael | March 7, 2018, 4:31 a.m. | Votes: 0 | [ VOTE ]

Your contribution cannot be approved yet. See the Utopian Rules. Please edit your contribution to reapply for approval.

  • I checked the README and I didn't find any commands to make it work or deploy it somewhere.

  • Do you have a test site for this? I want to try and check it myself. Can you please deploy this to heroku?

  • If I understood this project correctly, it's composed of a web app and a mobile app? What made you decide to put this into one github project? Wouldn't it be easier to maintain if you split them into two projects?

You may edit your post here, as shown below:
[IMAGE: https://res.cloudinary.com/hpiynhbhq/image/upload/v1509788371/nbgbomithszxs3nxq6gx.png]

You can contact us on Discord.
[utopian-moderator]

@steemthinkcom | March 7, 2018, 5:05 a.m. | Votes: 1 | [ VOTE ]

Hi~ @eastmael
Thanks for you reply.

  1. Yes steemthinkcom this platform contains the pc side and app side,
    I have deployed on github page, you can use https://steemthink.github.io/steemthink/ to view.
  2. ios and html templates on a project, due to operational errors, has been divided into two projects.
    ios: https://github.com/steemthink/steemthink-ios
    html: https://github.com/steemthink/steemthink
@eastmael | March 7, 2018, 5:41 a.m. | Votes: 1 | [ VOTE ]

Thank you for the contribution. It has been approved.

Please add the following to your project's README:
1. Link to the two projects - the web app and the mobile app
2. How to deploy locally (for the webapp)

And please note of also a similar project
* You need to clearly differentiate what your project aims to provide vs https://www.peerquery.com/

You can contact us on Discord.
[utopian-moderator]

@steemthinkcom | March 7, 2018, 6:08 a.m. | Votes: 1 | [ VOTE ]

readme has been modified
We also pay attention to peerquery.
Peerquery more like a platform for information aggregation, steemit the contents of the classification.
steemthink is a platform focused on providing knowledge sharing.
There are some differences in the orientation and development direction.

@eastmael | March 7, 2018, 6:09 a.m. | Votes: 0 | [ VOTE ]

Okay. That's good to know.

@utopian-io | March 7, 2018, 11:54 a.m. | Votes: 0 | [ VOTE ]

Hey @steemthinkcom I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
- Vote for my Witness With SteemConnect
- Proxy vote to Utopian Witness with SteemConnect
- Or vote/proxy on Steemit Witnesses

[IMAGE: https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif]

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

[ BACK TO TRENDING ] [ BACK TO MENU ]
CMD>