Nxt Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Nxt Client 1.11.2 - Announcement for Ardor (Nxt 2.0) is here. Ardor Tokens have been released!

Pages: [1]

Author Topic: Link to a new page for a plugin  (Read 1162 times)

MrV777

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 834
    • View Profile
  • Karma: +100/-4
Link to a new page for a plugin
February 01, 2016, 06:27:59 pm

Hello!

I'm a little rusty with my NRS javascript/html coding, but I'm trying to get back  :)
I was wondering if someone could help point out where I am going wrong here:
I have a plugin and on the first page I have a link to try and go to a new page:
Code: [Select]
<td><a href='#' class='goto-page' data-page='p_test_plugin_page2'>Test</a></td>in that same file I have the second page:
Code: [Select]
<div id="p_test_plugin_page2" class="page">
....
</div>

However, it doesn't switch to that page when I click the link.  It does nothing.  I don't see any errors in the Chrome Developer Tools' console either.  I have models working, but can't seem to crack the pages.

Thanks for any help!

Edit:  I also noticed this doesn't seem to do anything in my plugin modal (it never gets replaced):
Code: [Select]
<div data-replace-with-modal-template="fee_calculation_modal_template"></div>I'm guessing the javascript is breaking somewhere with my plugin (everything else still seems to work though), or there are limitations on what the plugins have access to use

Edit 2  :) Is there a way to do getDataTags, but only for a certain channel?  I'm trying to get tags under a certain category and the number of TaggedData objects there are with that tag under the channel.  Thanks again!
« Last Edit: February 01, 2016, 08:58:26 pm by MrV777 »
NXT: NXT-BK2J-ZMY4-93UY-8EM9V
NXT nodes: drseuss.dyndns-home.com, 198.46.193.111, 69.163.40.132, 192.169.6.103

MrV777

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 834
    • View Profile
  • Karma: +100/-4
Re: Link to a new page for a plugin
February 02, 2016, 01:14:30 pm

I feel like I'm missing something obvious.  The advanced button in my modal doesn't fire the function if you click on an advanced button link either.  I'm wondering if I have to include some javascript manually?  or if my plugin breaks some javascript, but it is isolated so it doesn't break everything.  Hmm...
NXT: NXT-BK2J-ZMY4-93UY-8EM9V
NXT nodes: drseuss.dyndns-home.com, 198.46.193.111, 69.163.40.132, 192.169.6.103

Riker

  • Core Dev
  • Hero Member
  • *****
  • Online Online
  • Posts: 1443
    • View Profile
  • Karma: +380/-42
Re: Link to a new page for a plugin
February 02, 2016, 03:14:01 pm

I feel like I'm missing something obvious.  The advanced button in my modal doesn't fire the function if you click on an advanced button link either.  I'm wondering if I have to include some javascript manually?  or if my plugin breaks some javascript, but it is isolated so it doesn't break everything.  Hmm...

Try adding the new page to the index.html file using the NRS.loadPageHTML() function.
If this resolves the problem, then we'll need to find a way to allow a plugin to dynamically load additional pages. From reviewing the code it looks like currently plugins are limited to loading a single page named 'html/pages/' + pluginId + '.html'

Regarding the getDataTags API, currently there is no way to filter the results by channel. You'll need to filter the results on the client side.
What is the use case for this ?
NXT Core Dev
Account: NXT-HBFW-X8TE-WXPW-DZFAG
Public Key: D8311651 Key fingerprint: 0560 443B 035C EE08 0EC0  D2DD 275E 94A7 D831 1651

MrV777

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 834
    • View Profile
  • Karma: +100/-4
Re: Link to a new page for a plugin
February 02, 2016, 04:09:28 pm

I'm trying (once again) make a plugin for a redit type interface using taggedData and prunable messages.  I can do everything I want to do from the test page, now I'm just trying to get it all in a plugin  :)
Thanks for the help, I'll try out your suggestion
« Last Edit: February 02, 2016, 04:20:52 pm by MrV777 »
NXT: NXT-BK2J-ZMY4-93UY-8EM9V
NXT nodes: drseuss.dyndns-home.com, 198.46.193.111, 69.163.40.132, 192.169.6.103

MrV777

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 834
    • View Profile
  • Karma: +100/-4
The Forum Plugin
February 02, 2016, 07:51:56 pm

So I did a little workaround and got a (mostly) working limited version of my plugin  :)
I'll make it available here.  There are a few known issues:
1.) Comments don't actually send the message, so they are left blank
2.) The comment box is current a text field instead of a text area because of testing
3.) Only NXT is a working category while I test and develop
4.) An image file is currently required
5.) Comment count is incorrect

Please only use this on the TestNet if you want to try it.

This link is good for 48 hours as I want to make sure old versions aren't left available while I continue to work on the code:
http://expirebox.com/download/5a8149b2eb16dcab7d6f551f67cfdf4b.html
« Last Edit: February 02, 2016, 09:10:42 pm by MrV777 »
NXT: NXT-BK2J-ZMY4-93UY-8EM9V
NXT nodes: drseuss.dyndns-home.com, 198.46.193.111, 69.163.40.132, 192.169.6.103

MrV777

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 834
    • View Profile
  • Karma: +100/-4
Re: The Forum Plugin
February 02, 2016, 09:20:35 pm

So I did a little workaround and got a (mostly) working limited version of my plugin  :)
I'll make it available here.  There are a few known issues:
1.) Comments don't actually send the message, so they are left blank
2.) The comment box is current a text field instead of a text area because of testing
3.) Only NXT is a working category while I test and develop
4.) An image file is currently required
5.) Comment count is incorrect
6.) Multiple categories doesn't work

Please only use this on the TestNet if you want to try it.

This link is good for 48 hours as I want to make sure old versions aren't left available while I continue to work on the code:
http://expirebox.com/download/5a8149b2eb16dcab7d6f551f67cfdf4b.html

This version should be better:
http://expirebox.com/download/e6a786255716c5878f179b7a2228bca7.html
 :)



« Last Edit: February 03, 2016, 02:47:30 am by MrV777 »
NXT: NXT-BK2J-ZMY4-93UY-8EM9V
NXT nodes: drseuss.dyndns-home.com, 198.46.193.111, 69.163.40.132, 192.169.6.103

Jean-Luc

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1553
    • View Profile
  • Karma: +785/-81
Re: Link to a new page for a plugin
February 03, 2016, 09:24:13 am

Is there a way to do getDataTags, but only for a certain channel?  I'm trying to get tags under a certain category and the number of TaggedData objects there are with that tag under the channel.
Unfortunately no, and this is very hard to do. The tag counts are stored in a single table, and the logic to update them is already complex, because of having to handle pruning and extending. I don't see a way to keep track of channel specific tag counts, given that channels are also free form and new ones can be added or disappear any time.

Do you use extendTaggedData, or referenced transactions for the comments? Now we have APIs to do it both ways, getTaggedDataExtendTransactions and getReferencingTransactions. Using referenced transactions will allow you to build a real discussion tree, a comment can refer to another comment instead of the top post only.
GPG key fingerprint: 263A 9EB0 29CF C77A 3D06  FD13 811D 6940 E1E4 240C
xmpp: jeanlucpicard@jabber.ccc.de EAFA3A2E 33B21A52 370CE6D4 35A4B325 3ED22061
NXT-X4LF-9A4G-WN9Z-2R322

MrV777

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 834
    • View Profile
  • Karma: +100/-4
Re: Link to a new page for a plugin
February 03, 2016, 01:20:40 pm

Is there a way to do getDataTags, but only for a certain channel?  I'm trying to get tags under a certain category and the number of TaggedData objects there are with that tag under the channel.
Unfortunately no, and this is very hard to do. The tag counts are stored in a single table, and the logic to update them is already complex, because of having to handle pruning and extending. I don't see a way to keep track of channel specific tag counts, given that channels are also free form and new ones can be added or disappear any time.

Do you use extendTaggedData, or referenced transactions for the comments? Now we have APIs to do it both ways, getTaggedDataExtendTransactions and getReferencingTransactions. Using referenced transactions will allow you to build a real discussion tree, a comment can refer to another comment instead of the top post only.

Interesting, I'm currently using extendTaggedData, but will look at referenced transactions.  That's okay about the tag count.  It is completely not necessary, it was just for an added feature of being able to see that.  I'll have a new version available soon for anyone that wants to test it or play with it.

Thanks for the input!

Edit: Newest version where commenting should work: http://expirebox.com/download/f8fafa936701e714c59a9f99d6397bae.html
Will look into reference transactions so people can comment on a comment  :)

Edit 2: Quickly fixed the multiple categories not working, so here is one with the fix: http://expirebox.com/download/8171bd832caa60ddd825fda8f2345e94.html  :)
« Last Edit: February 03, 2016, 02:21:39 pm by MrV777 »
NXT: NXT-BK2J-ZMY4-93UY-8EM9V
NXT nodes: drseuss.dyndns-home.com, 198.46.193.111, 69.163.40.132, 192.169.6.103

MrV777

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 834
    • View Profile
  • Karma: +100/-4
Re: Link to a new page for a plugin
February 03, 2016, 02:53:18 pm

Do you use extendTaggedData, or referenced transactions for the comments? Now we have APIs to do it both ways, getTaggedDataExtendTransactions and getReferencingTransactions. Using referenced transactions will allow you to build a real discussion tree, a comment can refer to another comment instead of the top post only.

I may be missing something.  How do I do a referenced transaction for a comment to a TaggedData object?  I see extendTaggedData has referencedTransactionFullHash (Which I still need to find the Full Hash  :)), is that all I need to fill out?  Your comment made it sound like I should do the reference transaction without doing the extendTaggedData though
NXT: NXT-BK2J-ZMY4-93UY-8EM9V
NXT nodes: drseuss.dyndns-home.com, 198.46.193.111, 69.163.40.132, 192.169.6.103

Jean-Luc

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1553
    • View Profile
  • Karma: +785/-81
Re: Link to a new page for a plugin
February 03, 2016, 03:15:53 pm

You can use a simple arbitrary message (prunable) transaction, with no recipient, and referencedTransactionFullHash set to the full hash of the tagged data upload transaction.

Now that we have archival nodes, and you can add retrieve=true parameter to getTaggedData to force its retrieval from an archival node if missing, the extend tagged data functionality is not that useful anymore.
GPG key fingerprint: 263A 9EB0 29CF C77A 3D06  FD13 811D 6940 E1E4 240C
xmpp: jeanlucpicard@jabber.ccc.de EAFA3A2E 33B21A52 370CE6D4 35A4B325 3ED22061
NXT-X4LF-9A4G-WN9Z-2R322

Jean-Luc

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1553
    • View Profile
  • Karma: +785/-81
Re: Link to a new page for a plugin
February 03, 2016, 03:24:35 pm

Or you could set the recipient to the tagged data author, so that it appears in his recent transactions list that someone commented on his upload.
GPG key fingerprint: 263A 9EB0 29CF C77A 3D06  FD13 811D 6940 E1E4 240C
xmpp: jeanlucpicard@jabber.ccc.de EAFA3A2E 33B21A52 370CE6D4 35A4B325 3ED22061
NXT-X4LF-9A4G-WN9Z-2R322

MrV777

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 834
    • View Profile
  • Karma: +100/-4
Re: Link to a new page for a plugin
February 03, 2016, 04:14:36 pm

You can use a simple arbitrary message (prunable) transaction, with no recipient, and referencedTransactionFullHash set to the full hash of the tagged data upload transaction.

Now that we have archival nodes, and you can add retrieve=true parameter to getTaggedData to force its retrieval from an archival node if missing, the extend tagged data functionality is not that useful anymore.

Thanks!  I'm changing my code now to use messages instead of extend tagged data.  I'm thinking I'll need to check every referencing transaction to see if it has a referencing transaction (good ole loop inside a loop  :)).  I noticed getChannelTaggedData doesn't have the retrieve option, is there a reason for that?

I learned something new too when this message popped-up: Due to you using a referenced transaction hash, 100 NXT is held in custody until the transaction is confirmed or expires.  :) Looks like the fee for doing it this way is double too, hopefully that won't be an issue
NXT: NXT-BK2J-ZMY4-93UY-8EM9V
NXT nodes: drseuss.dyndns-home.com, 198.46.193.111, 69.163.40.132, 192.169.6.103

Jean-Luc

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1553
    • View Profile
  • Karma: +785/-81
Re: Link to a new page for a plugin
February 03, 2016, 05:05:59 pm

Retrieving pruned data is potentially expensive as it does not fail until it has tried all known archival nodes. This is why I have it only for API requests that return one data at a time.
GPG key fingerprint: 263A 9EB0 29CF C77A 3D06  FD13 811D 6940 E1E4 240C
xmpp: jeanlucpicard@jabber.ccc.de EAFA3A2E 33B21A52 370CE6D4 35A4B325 3ED22061
NXT-X4LF-9A4G-WN9Z-2R322

MrV777

  • Core Dev
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 834
    • View Profile
  • Karma: +100/-4
Re: [PLUGIN] The Forum v0.8
February 03, 2016, 05:14:48 pm

Retrieving pruned data is potentially expensive as it does not fail until it has tried all known archival nodes. This is why I have it only for API requests that return one data at a time.

That makes sense.  Thank you for all the info and insight.  I have a version mostly working for the TestNet now with referenced transactions:
http://expirebox.com/download/e3ebaf4981a67f1044162710e8d6e313.html

Known issues:
1.) Still have to include an image file even though I don't use it currently
2.) Only one level of nested comments

Once I take care of issue 1 above (which is caused by a check in nrs.server.js it looks like), I'll take a look into how this plugin will function once information starts getting pruned






Edit: I see that nrs.server.js requires a file to be included for uploadTaggedData, but the API doesn't require this.  I wonder if there was a reason for that.  I specify isText as true, but it still wants that input filled out even though it does not get used.
« Last Edit: February 03, 2016, 08:02:11 pm by MrV777 »
NXT: NXT-BK2J-ZMY4-93UY-8EM9V
NXT nodes: drseuss.dyndns-home.com, 198.46.193.111, 69.163.40.132, 192.169.6.103
Pages: [1]