SteemMakers website update

in #utopian-io6 years ago

So jef, where have you been hiding, what's next? The image above says it all. I've been learning, and learning yields no direct results. The last two weeks have been a little frustrating. Every time I wanted to add a feature there was something new to learn, and trying to use that new knowledge I hit obstacles that required some more knowledge.

Development environment

A basic aspect of website development is being able to test certain features away from the production server. In the current conversion to a SPA I never had the need for this until now. Unfortunately it didn't went smooth at all. The basic idea is simple but the Vue typescript example provided by Microsoft is incomplete and so was my knowledge. Somehow the build was not taking my data that was to be switched between development and production. When many hours of googling did not yield to a solution I tried stackoverflow: Dynamically add global constant in webpack. I'm not the type of person to post a question and stop searching. The next day there still was no response and somehow I ended on this blog post. There are some small details at the end of the article that caught my eye. Putting all things I read together I realized there was something missing in the typescript template I started from. Searching for confirmation i found nothing in the provided documentation but found an issue on github pointing in the direction I was on.

The vue typescript template build script:

"scripts": {
"build": "webpack",
"test": "echo \"Error: no test specified\" && exit 1"
}

the vue template:

"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},

And sure enough simply changing the script to

"scripts": {
"build": "SET NODE_ENV=development&& webpack",
"test": "echo \"Error: no test specified\" && exit 1"
},

solved the problem. I hate it when in the end it proves to be such a simple fix.

Spinners for asynchronous loading

The previous update showed how the paging was added and how the new site now also allows for content discovery. We don't store the articles ourselves, the content is fetched from the blockchain, but we do keep references so we know which articles to fetch. Because we try to serve these previews as fast as possible they are loaded asynchronously. When the connection is slow, or the blockchain servers are under heavy stress, this might lead to confusing behavior to the user. The idea was to add a simple spinner for every article while loading. A simple feature at first but it again proved to be a major stumbling block. The root cause being the javascript language itself. It just seems it was not designed for developing this kind of things. It is capable of doing so, but it's a mess and hard to debug. The issue here was that Vue js claims to be similar to MVVM which I know very well but there are so many edge cases where it behaves differently or where one needs to think about how stuff works behind the scenes. I again resided to the Vue.js forums to ask for help. To put it blunt a workaround needed to be implemented because of limitations withing the notification system. This is a simulation of a slow connection. You can see how articles are loading asynchronously:

testje.gif

Vuex and login

Vuex is a state management system for Vue.js applications. In the end this didn't prove to be too hard to implement but coming from an object oriented background it feels strange to use a global object like this. I still wonder how big applications manage to prevent their design of becoming one big spaghetti.
The basic login process is now also ported to the SPA.

testje.gif

What will come next?

Next up is managing the user rights and give certain user rights to add articles to our database from within the app. I hope that doesn't turn out to be as frustrating as the past two weeks.

Help us out

Anyone interested is free to join and help out, all work is available on Github. More information can be found on our website www.steemmakers.com, have a look and join us on Discord!

Proof of Work Done

Repository: https://github.com/JefPatat/SteemMakers/tree/master/website

My github account: https://github.com/JefPatat

Relevant commits: several commits from May 16th to May 27th: https://github.com/JefPatat/SteemMakers/commits/master

footer.png

Image source: the internet...

Sort:  

Becareful when using Vuex, I happen to goes down to a state management pitfall when I first learning about building SPA. Don't put anything on action/mutation, only put something that globally use across component (I happen to put all fetch api call in action when I first learn it 😅).
Some feature that I think you can put on vuex is:

  • settings (including theme customization like dark and light theme)
  • login state (well done)

When your state became bigger (only if become bigger), you may want to refactor it into separate Vuex module.

Also, if you plan to persist the state of the webapp (so that all states not being reseted when user accidently hit refresh button), there is a plugin for it (or you can implement it manually by storing-fetching the state into-from window.sessionStorage)

Lastly. Just curious, any reason/problem why you are not using vue-cli 3?

I quite hate the concept of global things. They act like gods and we all know what too many gods do (Roman, Greek, Scandinavian, ...) They make a mess. Using javascript (typescript) feels like I must give up on quite some programming concepts because the language simply doesn't allow for them. Programming in this language seems so much less efficient.

Not planning in storing the state in storage. That's vulnerable to xss -> https://stormpath.com/blog/where-to-store-your-jwts-cookies-vs-html5-web-storage

I've read about vue-cli 3 and it appeals but it's still in beta. That and I started from the MS template before I learned about vue-cli 3.

I know how you feel man 😂. I have background developing backend on C# and my first SPA framework I touch is Angular (more precisely Ionic 2). Almost OO design pattern not work in this Component thingy.

And yes, the secure place to store credentials is Cookies. For mitigating XSS in web storage state management, the only way to mitigate that is to perform validation check which is quite cumbersome at the current moment. (thankyou for the article)

Lastly, you will be surprised when vue-cli 3 released and then they announce vue-ui which is the UI dashboard for vue-cli 😆

ohm didn't know about vue-ui, I'll need to look into that. thx.

  • Great project and visuals
  • Code base could benefit from more comments.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thanks @helo. I'm kind of a comment minimalist. The only exception being APIs. I know it's a metric in Utopian but I don't consider it a good one. Maybe I should write it up in a post once as it seems to be something I lack every time.

Thanks for the note, love the meme.

I didn't know about STEEMMAKERS! Such a cool idea...I personally love spending time reading what others create...like DIY Redditt subredditt is my homepage pretty much, now I have my DIY blockchain-based instead, even better! Those amazingly yummy loaders, please push them to master! :)

Feel free to join, we're open to everybody!

And the loaders... It's even better not to see them ;-)

yeah but there are so juicy...eheh...joining the Discord in the meantime

Hey @jefpatat
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.030
BTC 65185.94
ETH 2630.94
USDT 1.00
SBD 2.83