Programming Diary #3: Connecting with git; individual account entry; beneficiary settings and more use of metadata
Here is a summary of my progress from January 9 through yesterday while learning to use SteemJ and Java/Swing to interact with the Steem blockchain.
Introduction
Pixabay license, source
At the end of my previous Programming Diary post, I laid out a set of "to do"s, and during the last two weekends, I started chipping away at some of them. This post will describe some of my progress. This week's activities focused mostly on connecting Netbeans and git, learning to add a pop-up window to enable manual entry of the account name and Posting key, and adding the capability to auto-populate the publication date. In summary, here's the full list from last week, with checkboxes to denote some forward motion.
- [_] Figure out how to download the functional version of SteemJ and update its dependencies to current versions.
- [x] Manual entry of account name and Posting key (in a password field).
- [_] Add fields to specify tags.
- [x] Figure out how to apply beneficiary settings to a post through SteemJ.
- [x] Provide a checkbox and entry field to set @penny4thoughts as a beneficiary and specify the percentage.
- [~] Figure out how to scrape the publication date from a web site using jSoup.
- [_] Put min/max lengths on blockquotes and author commentary.
- [_] Require a publication date.
- [_] Protect against accidentally double-posting from the same form data (clear form after posting).
- [_] Protect against accidentally clearing the form before posting.
- [_] Add the ability to "preview" a post before submitting to the blockchain.
- [~] Lots of error handling, all over the place.
Entries with an "x" were accomplished, entries with an "_" were not, and entries with a "~" moved forward but were not completed. See the conclusion section of this list for some additional items that occurred to me during recent activities.
Connecting Netbeans and git
One of the early mistakes I made was to set up my NetBeans project directory on a shared drive that was accessible by multiple computers and try to use it from multiple work locations. It turns out that multiple instances of Netbeans don't necessarily play well together when using the same project directory at the same time. In order to get past this, and also to set the stage for collaboration in the future, I moved the code to a private repository and configured Netbeans to pull from there. Now, I can share code between devices more cleanly through the use of git's standard pull/commit/push mechanisms. It's also ready for collaboration with others, and I already shared access with @primevaldad and @cmp2020.
Entering posting keys through a pop-up window
It may not seem like much, but since I'm barely more than a novice with Java, it was actually a challenge for me to create a pop-up window and to collect posting keys. After some fiddling, here's what I came up with:
As with other graphics, I'm using Java/Swing for the window. The pop-up window works so that the account and posting key only need to be saved once, and then they can be reused for multiple posts.
Beneficiary settings
One thing that came as a surprise to me is that SteemJ sets a default beneficiary setting of 2 1/2% to the @steemj account. When I discovered that, it was easy enough to change the default beneficiary from @steemj to @penny4thoughts, and to enable changing it from within the form. So, I declared "mission accomplished" on my desire to add @penny4thoughts as a beneficiary. This can also be seen in the image above.
However, I don't want to cut @steemj out, and the blockchain allows us to enter up to 8 beneficiaries, so I have now added a new item to my checklist to enable the use of multiple beneficiary settings. Unfortunately, from what I've found so far, this may require changes to SteemJ, so it's probably a goal for the long term, not the short term.
Scraping metadata
The published date doesn't seem to be a common value in the Open Graph information from the articles that I have looked at, so I have begun looking for other fields. It seems like this will continue to evolve as the program moves forward. Here is the code that I have currently directed to this purpose ("d" is passed in as a jSoup "Document"):
int IRC=1; try { publishedDate = d.select("meta[property=og:updated_time]").first().attr("content"); IRC=0; } catch ( Exception E) { IRC=1; } if ( IRC != 0 ) { try { publishedDate = d.select("meta[property=article:published_time]").first().attr("content"); IRC=0; } catch ( Exception E) { IRC=1; } } if ( IRC != 0 ) { try { publishedDate = d.select("meta[name=date]").first().attr("content"); IRC=0; } catch ( Exception E) { IRC=1; } } if ( IRC == 1 ) { publishedDate = "Enter manually."; }
Sample Post
As-of now, here is the full posting process, from beginning to end:
Enter the URL and click on "Auto-Populate"
Enter a blockquote, add author commentary, set desired beneficiary settings.
Generate Markdown/HTML
Enter Posting Credentials and click on "Save"
Click on "Post to Steem"
And here is the resultant post, Why the government is raising an eyebrow at Gen Z's favorite new way to spend: 'Buy now, pay later' - Business Insider
Conclusion
So there's a summary of my progress the last two week-ends. Goals accomplished from this week included connecting Netbeans and git, adding @penny4thoughts as an optional beneficiary, enabling entry of the account name and posting key to be used for posting. I should note that I am continuing to use the account, @social, since some unknown party published its posting key and it is convenient to use for testing without risking accidental disclosure of my own keys.
- [_] Find a way to add multiple beneficiaries
- [_] Additional jSoup web scraping for alternate publication date formats, and possibly to suggest categories/tags/keywords.
- [_] Identify open source software and do security audit of SteemJ and my own code. One possible starting point appears to be: OWASP
- [_] Cosmetic improvements (look & feel - maybe JavaFX and/or CSS)
- [_] Change "Save" to "Save & Exit" in pop-up form for account entry
- [_] Prevent posting with stale data in the autogenerated HTML after updates/corrections in other fields.
- [_] HTML/Markdown preview option before posting.
- [_] Spell check in author commentary
- [_] Tag length and character-type validation
As with last week's post, the following beneficiaries have been applied to this post:
Update: Guess my fingers were typing faster than my brain was thinking. Not that it matters much, but I didn't actually use "github", just "git". Suitable substitutions have been made above.
Thank you for your time and attention.
As a general rule, I up-vote comments that demonstrate "proof of reading".
Steve Palmer is an IT professional with three decades of professional experience in data communications and information systems. He holds a bachelor's degree in mathematics, a master's degree in computer science, and a master's degree in information systems and technology management. He has been awarded 3 US patents.
This is great progress. Nice work!
I'd like figure out how to connect an HTML front end to this.
Any leads for me that will point me in the right direction to work on that?
Yeah, I'm trying to figure out how to connect it to HTML & CSS, too. Netbeans has indications that it can be accomplished directly or through javafx, but I haven't been able to work through to the details yet.
I think applets have been deprecated for security reasons, and Swing - that I'm using, is also apparently not the best solution. I have some JavaFX links in last week's post.
It's been a while since I programming in Java. But it was very effective and easy to learn.
Using Github for code management is definitely a good investment. Setting it up takes time. But now you can spend more time to the code adaptation. Continued success!
I love learning this programming and I will continue to pay attention to the development of the steemj program that you are working on. The results of your posts using this programming are more beautiful than ever. There is the date of posting and the name of the website link.
I will continue to follow your publications on this and will try to study when I have more free time in this mid year.
Thanks for post the update
Best Regard
@aafadjar
Hey remlaps
Would you answer if in case I need some
computing knowledge in future? What you ha
ve posted here is really helpful and I'm gonna
need then all but I'm not capable of learning so
much at a time.
Hi, I'll be happy to answer questions, if I am able.
Thank u.
I see a lot of progress, they are focused on moving forward and you are certainly achieving it, the part that you talk about the keys, seems very correct to me, there is so much, like calling it, envy, it is the word, that it is better to be forewarned.
I wish you a happy Tuesday