HelloZeroNet / ZeroNet

ZeroNet - Decentralized websites using Bitcoin crypto and BitTorrent network
https://zeronet.io
Other
18.38k stars 2.27k forks source link

Universal admin interface #354

Open HelloZeroNet opened 8 years ago

HelloZeroNet commented 8 years ago

We need an universal admin interface that allow to manage data stored on sites.

Features needed:

This would be huge benefit for all ZeroNet sites, so it would be really nice if someone would be able to take this task, so I will be able to focus on core modifications.

HelloZeroNet commented 8 years ago

Example jsx config file for ZeroTalk:

<Site title="ZeroTalk">

 <Page name="topic" title="Topics" orderby="added DESC">
  <user name="json_id" title="Username" disabled save="no"/>
  <input name="added" formatter={ Date.toDate } deformatter={ Date.fromDate }/>
  <input name="title"/>
  <textarea name="body"/>
  <select name="type" values={ ["", "group"] }/>
  <select name="parent_topic_uri" title="Parent topic" values={ Topics.listUris }/>
 </Page>

 <Page name="comment" title="Comments" orderby="added DESC" parent="topic">
  <user name="json_id" title="Username" disabled save="no"/>
  <input name="added" formatter={ Date.toDate } deformatter={ Date.fromDate }/>
  <textarea name="body"/>
  <select name="topic_uri" title="Topic" values={ Topics.listUris }/>
 </Page>

 <Page name="settings" title="Settings" file="content.json">
  <input name="settings.admin" title="Admin name"/>
  <input name="settings.href" title="Admin contact url"/>
  <select name="settings.sticky_uris" title="Sticky topic uris" multi values={ Topics.listUris }/>
 </Page>

</Site>

Based on simple config this tool would able to generate an admin interface that allows the site owner to modify/delete/move topics and comments.

Update: added Settings page

icf20 commented 8 years ago

maybe you want to consider a new option; preserve zeromail contact content across al local sites

alxbob commented 8 years ago

Great option! Lets to it!

vlad20012 commented 8 years ago

I'm the only one who does not understand why we need a "universal" interface, not just admin/user page on ZeroTalk/ZeroBlog using normal JS?

HelloZeroNet commented 8 years ago

Because then you don't have to re-write the same functions for every site you make, does not bloats the main source code, better tools (eg. batch modify), user management, custom listings, etc.

I already created a similar tool: http://i.imgur.com/cV8mju1.png It saved me many-many working hours. I'm able to create fast and unified admin interfaces using this, every operation is logged and reversable, easy form validations, batch editing, reordering etc. The sites are only different from xml configuration files, so if i add a new function/enhancement every site will benefit from it. Unfortunetly it's not portable to zeronet, but I think we need to create a very similar one.

crazysoldier commented 8 years ago

wow can someone give me the code for an admin interface on my own page?

obv-mikhail commented 8 years ago

So a content management system like WordPress, but for ZeroNet sites?

obv-mikhail commented 8 years ago

Is this supposed to be a separate tool or a python plugin with functionality accessible to any website by its owner?

HelloZeroNet commented 8 years ago

It should be a standard zeronet site

obv-mikhail commented 8 years ago

Instead of using configuration files we can use a simpler component approach.

HelloZeroNet commented 8 years ago

pure js also could work, have to try which one is easier to read/extend by creating examples for zerotalk/zeroblog/zeromail

obv-mikhail commented 8 years ago

This how it would look like for ZeroTalk.

window.ZeroTalkAdmin = new ZeroAdmin "ZeroTalkAdmin", {
    "topic": ZeroAdmin.page({title:"Topics", orderby: "added DESC"}, {
        "json_id": ZeroAdmin.user({title: "Username", disabled: 1, save: 0}),
        "added": ZeroAdmin.input({formatter: Date.toDate, deformatter: Date.fromDate}),
        "title": ZeroAdmin.input(),
        "body": ZeroAdmin.textarea(),
        "type": ZeroAdmin.select({values: ["", "group"]}),
        "parent_topic_uri": ZeroAdmin.select({title: "Parent topic", values: ""})
    }),
    "comment": ZeroAdmin.page({title:"Comments", orderby: "added DESC", parent: "topic"}, {
        "json_id": ZeroAdmin.user({title: "Username", disabled: 1, save: 0}),
        "added": ZeroAdmin.input({formatter: Date.toDate, deformatter: Date.fromDate}),
        "body": ZeroAdmin.textarea(),
        "topic_uri": ZeroAdmin.select({title: "Topic", values: ""})
    }), 
    "settings": ZeroAdmin.page({title:"Settings", file: "content.json"}, {
        "settings.admin": ZeroAdmin.input({title: "Admin name"}),
        "settings.href": ZeroAdmin.input({title: "Admin contact url"}),
        "settings.sticky_uris": ZeroAdmin.select({title: "Sticky topic uris", multi: 1, values: ""})
    })
}
HelloZeroNet commented 8 years ago

looks good for me, maybe a bit easier to read the xml version, but I also prefer pure js over jsx, because of "less magic"

Snarkly commented 8 years ago

Admin Panel tutorials https://www.youtube.com/watch?v=oxGmXOKazw0 https://www.youtube.com/watch?v=SSAQK4Nwkm4&feature=youtu.be https://www.youtube.com/watch?v=mysAB7NAjDk&feature=youtu.be https://www.youtube.com/watch?v=Ct8NKKlsiMM

obv-mikhail commented 8 years ago

How does dbQuery query work? I am currently using timeouts to make sure that data is fetched before proceeding with rendering. Is there a different workaround for this?

Can the database file be loaded into the site with fileGet? If so it might be a good solution to use sql.js.

HelloZeroNet commented 8 years ago

Its verry simple, but the chat tutorial has example for dbquery. Loading database file using fileGet is a bad idea and does not makes much sense.

obv-mikhail commented 8 years ago

How would I access 'table' variable from within the callback function?

        for table in @tables
            Page.cmd "dbQuery", ["SELECT * FROM "+table.name], (res) =>
                @columns[table.name] = res

Its value changes to @tables[16] by the time callbacks are called. I need a way to pass it to the function as a parameter maybe.

HelloZeroNet commented 8 years ago

This should work:

checkTable: (table_name) =>
    Page.cmd "dbQuery", ["SELECT * FROM "+table_name], (res) =>
                @columns[table_name] = res

for table in @tables
   checkTable(table.name)

part to separate function, then it should work

HelloZeroNet commented 8 years ago

userPublickey is for ecies encryption. the user's auth_address is in site_info object (please check the zerochat tutorial)

Snarkly commented 8 years ago

I found a few coders on youtube who know about admin panels and I'm contacting them to see if they can help create an admin panel for ZeroNet. I also found some other admin projects on github that might give you some ideas. https://github.com/xkv/PixelAdmin-CN https://github.com/puikinsh/Bootstrap-Admin-Template https://github.com/yogiben/meteor-admin https://github.com/cms-dev/cms https://github.com/guru-digital/frontend-admin

obv-mikhail commented 8 years ago

HelloZeroNet, maybe create an official (empty for now) repository, like for ZeroTalk etc? Would make more sense to discuss things in there.

HelloZeroNet commented 8 years ago

Good idea, created and added some thing before start coding: https://github.com/HelloZeroNet/ZeroAdmin/issues