Question for Wordpress coders

Discussion in 'Tech Discussion' started by jacobpaige, Aug 18, 2018.

  1. jacobpaige

    jacobpaige Well-Known Member

    Joined:
    Dec 22, 2015
    Messages:
    10,104
    Likes Received:
    3,732
    Reading List:
    Link
    I've got a sqlite database that I recently made and I'm planning to use it to create a theorycrafting tool for an old game. It occurred to me that there might be a handful of other people that are still playing the game and could benefit from the tool, and that I had a free Wordpress account that I'm not really using for anything but commenting. So, I was wondering if it would be possible to create an in-browser app on a page of my WP account. Unfortunately, I'm not sure how to phrase this question in a way that Google-sensei can understand, nor evaluate if I've found the right answer.

    From the searches that I've tried, I think it's possible if I download WP and create a WP site with that, but I'm not sure if I could then use that site with my free WP account, or what would happen to the info/comments on my current site.

    If it helps, the eventual app would just be a series of dropdown menus populated with sqlite queries, maybe some text entry fields that would generate their own sqlite queries, some stuff on the backend to do necessary calculations and some sort of output of the results of those calculations.

    Can anyone tell me if this is possible without having to upgrade my WP account? And if so, what tools I'll need? If you have a tutorial you can point me to, even better. Though, just knowing how to phrase the question so Google will understand would also be very helpful. I'm sure this question has been answered already if I can just figure out how to ask it.
     
  2. UsernameJ

    UsernameJ Well-Known Member

    Joined:
    Jan 5, 2016
    Messages:
    636
    Likes Received:
    611
    Reading List:
    Link
    You need to understand the difference between the WordPress software and the WordPress website.

    The software is a way of creating web pages. After you have the web page created, it needs to be hosted in order to be accessible to other people. You could for example just host the website on an FTP server and anyone who has access could load the html or whatever that way, but usually people want a webhost so they can get a URL and people visit their site that way.

    The website is basically the wordpress software and a host for you already. You can make a free wordpress website that is hosted by wordpress for free by just going to their website and making a blog. Your options for customization are limited in some ways if you go this route though. If you make a wordpress blog hosted by wordpress by going through their site, you have no access to the actual backend of the blog itself (CSS, writing HTML and PHP, etc).

    Doing what you want to do, you probably can't do it by going through the wordpress website for free. Hosting a website really requires a domain to go with it, and I don't think there are any free domain services. Some are really cheap (like dollars a year) but none are really free I think.
     
  3. TamaSaga

    TamaSaga Well-Known Member

    Joined:
    Oct 11, 2016
    Messages:
    1,726
    Likes Received:
    2,173
    Reading List:
    Link
    Hmm...unfortunately, I think this wouldn't be possible with a free WP account. If it was just javascript, I'm pretty certain you can fudge the free account's security a little so that it could execute scripts. Then you can run the javascript after jumping through a few hoops.

    The problem is that sqlite file. The free account doesn't allow you to work on the backend, where you would place the sqlite file. If you can't even store your sqlite file, you can't even think about ways to use a script to run queries on that file.

    I mean, if you tried hosting the sqlite file on a file storage site and attempted to have a client access it from your wordpress site, you run into cross-site script security issues. Pretty certain that you would need access to the backend on the file storage site to write the headers necessary to prevent the client's browser from slamming the "No" button.

    Ultimately, to do what you're asking for without upgrading your WP account, I think you will need to:
    - Keep your free wordpress.com account
    - Buy a new account.
    - Follow tutorials to export your wordpress.com account to a hosted account.
    - Proceed to use what you have already researched to pull off what you want.

    Or Plan B
    - Keep your free wordpress.com account
    - Buy a new account.
    - Develop the tool on the new account.
    - Link to the tool from your free wordpress.com account

    Yes, I know I'm completely redefining what you're asking for, but I'm fairly certain that just doing it with the free option is currently not legally possible.

    Personally, I'd offer to rent out some of my friend's server space for free since it sounds like your site requirements will barely take an iota of resources, but there are some caveats, like you'd need to supply your own domain name.
     
  4. Kaminomikan

    Kaminomikan 神のみ感

    Joined:
    Feb 8, 2016
    Messages:
    983
    Likes Received:
    1,071
    Reading List:
    Link
    no, what you are looking for is to host some kind of webapp, wordpress free doesn't allow that, and if you are going to invest cash then wordpress wouldn't be the best choice for that.
     
  5. jacobpaige

    jacobpaige Well-Known Member

    Joined:
    Dec 22, 2015
    Messages:
    10,104
    Likes Received:
    3,732
    Reading List:
    Link
    I don't mind doing it in javascript instead. Learning javascript or learning PHP, it's likely about the same in terms of effort afaik.

    That said, I just put the information in a sqlite db because I figured it'd be faster and easier to access and manipulate the info. I've still got all the info in the csv files I used to create the db if those could be used with a free WP account.

    Also, would it be possible to simply create a plugin that generates a widget that is the tool and then somehow use that to post the tool to a page? Sorry if this is a dumb question. I've really not done anything with web programming before.
    Nah, if I can't do it for free, then I'll just create a windows app and post the .exe on GameFAQs for those interested in it and brave enough to download a .exe from an unknown source.
     
  6. TamaSaga

    TamaSaga Well-Known Member

    Joined:
    Oct 11, 2016
    Messages:
    1,726
    Likes Received:
    2,173
    Reading List:
    Link
    Nope. I just saw a site comparing wordpress.com (what you're probably using) and wordpress.org (a paid hosting site), and I saw that you don't have any control over the plugins that you can use. Sure you can write a plugin, but you won't be able to use it on your free site.

    I wonder if you can use csv files...first you would give it an image file so you can upload it, then you would use javascript to access those files and read the relevant data.

    But Wordpress makes javascript extremely difficult to work with already. I really think you'd save yourself from a lot of time and headaches if you just went the proper route.
     
    Last edited: Aug 18, 2018
    jacobpaige likes this.
  7. jacobpaige

    jacobpaige Well-Known Member

    Joined:
    Dec 22, 2015
    Messages:
    10,104
    Likes Received:
    3,732
    Reading List:
    Link
    Guess I'll just go with a desktop app then. Thanks everyone :)
     
  8. TamaSaga

    TamaSaga Well-Known Member

    Joined:
    Oct 11, 2016
    Messages:
    1,726
    Likes Received:
    2,173
    Reading List:
    Link
    Yes, that may be best given the current options.

    I'd recommend that you still jump through the hoops of obtaining a domain name and hosting space so that you can learn how to create and maintain a website though, I've found it to be a very sellable skill.
     
  9. jacobpaige

    jacobpaige Well-Known Member

    Joined:
    Dec 22, 2015
    Messages:
    10,104
    Likes Received:
    3,732
    Reading List:
    Link
    If I had any money to spare, I'd go ahead and do that. Unfortunately, I have to care about every single dollar I spend at the moment.
     
  10. TamaSaga

    TamaSaga Well-Known Member

    Joined:
    Oct 11, 2016
    Messages:
    1,726
    Likes Received:
    2,173
    Reading List:
    Link
    You can turn your desktop into a private web server just by downloading a preconfigured WAMPP or LAMPP package. Like Xampp.

    One problem is that it's not very exciting when developing for yourself. And not only that, I've found that web programming generally requires two to three times as much work since you also need to develop a backend that communicates with the database and supplies information to the frontend. This unlike a standard desktop app where the frontend directly communicates with the data source. It's a pain.
     
  11. Kaminomikan

    Kaminomikan 神のみ感

    Joined:
    Feb 8, 2016
    Messages:
    983
    Likes Received:
    1,071
    Reading List:
    Link
    to learn to maintain a website you don't need to buy a domain and hosting, just download a webserver and you can try test all kind of environments, wordpress, joomla, php pure, etc etc. and if you have a sturdy pc and internet connection you can go online. (after applying some security measures)
     
  12. lnv

    lnv ✪ Well-Known Hypocrite

    Joined:
    Jan 24, 2017
    Messages:
    7,702
    Likes Received:
    9,044
    Reading List:
    Link
    How about this, make a gitlab or github account and then link to it from your wordpress? They support running javascript just fine.

    You can use indexdb (or an easier to use LocalForage wrapper), if you want sql syntax, there are some sql databases that run on top of indexdb/localstorage.

    If you are too lazy to make an account you can use jsfiddle or codepen. That is what I did for the character stat calculator for my novel. Though I used flat json file storage instead of a db since the data is mostly static.

    Here is an example of what I did: (I suggest using changeview or hiding the code part for better viewing)

    https://codepen.io/anon/pen/odXQaR

    I just wrote the javascript and saved it on codepen without making an account and got a link I could use directly.
     
  13. jacobpaige

    jacobpaige Well-Known Member

    Joined:
    Dec 22, 2015
    Messages:
    10,104
    Likes Received:
    3,732
    Reading List:
    Link
    I'll consider it after I've got the current project worked out. I find I'm more motivated when making something for distribution rather than for just myself. Well, assuming that Inv's suggestion doesn't work out anyway.
    I've already got a github, though I've never tried using it to actually execute code. I wasn't aware it was even an option. Do you know any tutorials for what I'd be trying to do? Or the technical terminology for it so that I can research it myself? And would the javascript still be able to access a database, or would I need to use the csv files/JSON objects?
     
  14. lnv

    lnv ✪ Well-Known Hypocrite

    Joined:
    Jan 24, 2017
    Messages:
    7,702
    Likes Received:
    9,044
    Reading List:
    Link
    Github has a thing called github pages. It creates a subdomain under github that shows your webpage that is on github.

    On how to make the github pages? or how to code what you want?

    To answer that question would depend on if you are thinking about a database that give read/write access to everyone, read/write access to a single user or read only access to everyone.

    If you are looking for read/write access to everyone (where people save their data and others can view it), for that you need database hosting. You can still access this data via a REST api though. But this is more complex.

    If you are looking for read/write access for the user only, then you can use indexdb or localstorage that is built into every browser. You can have the user export and import their saves to prevent situations where they clear their cache or the like, but unless they clear their cache the data is persistent. If you don't care about long term storage, you can just work with javascript variables and export the json or csv or w\e you want

    If you are looking to just pull static values from a dataset, it can be in any format. Json, CSV, you can even load sqlite files. Example of sqlite:
    https://github.com/kripken/sql.js

    As long as you are accessing within the same domain name, it is not a problem of almost any format. (which is the case for github). But again it will be read only. You can export saves and have reload them via import though.

    Though I suggest json because it has the least overhead and makes things less complicated unless you really need to run sql queries.
     
  15. jacobpaige

    jacobpaige Well-Known Member

    Joined:
    Dec 22, 2015
    Messages:
    10,104
    Likes Received:
    3,732
    Reading List:
    Link
    Ah, I'll look into it. Thanks :)

    I thought you were saying to execute the code on github itself, but I had no clue how to do it. I'm sure github pages will have its own tutorials and there's tons of tutorials out there for making webpages.

    It would be strictly read only for anyone using it on the site. If I want to change the database, I'll do it myself and commit it through github. I mostly wanted the sql queries so that I could limit the options in the dropdown menus based on selections made in other menus and textboxes so that people would only have access to options that would be available to them under specified conditions. I'm sure I can work out an alternative method to do the same thing though. It's just that it probably won't be nearly as efficient. Still, the data sets are relatively small (128KB for the entire db), so it's probably not that big of a deal one way or the other.
     
  16. lnv

    lnv ✪ Well-Known Hypocrite

    Joined:
    Jan 24, 2017
    Messages:
    7,702
    Likes Received:
    9,044
    Reading List:
    Link
    The execution happens fully in the browser, github merely lets you host javascript code while wordpress does not (unless you pay or have your own hosting).

    Then what you want is extremely simple, and easy to do with javascript on github.

    I highly suggest using json files. It makes it a ton easier. Notice the code I made for my novel to generate the stat pages? It is fully conditional. For example, click on the character Shiro, then look at Choose Chapter. It has a bunch of options. If you switch characters, the fields options change. Or if you keep on Shiro, enable Equip. Then click on equipment and notice it is blank. As you go through chapters, new equipment shows up that you can add and remove.

    The conditions are simply placed directly in the javascript, but are based on the data in the json files. (Though I suggest using an ide on your pc that can make the json pretty so it is easy to read and write, otherwise it can seem unreadable)

    Here is one of my json data files:
    https://api.myjson.com/bins/8zzhv
    Copy it to here to make it pretty:
    https://jsonformatter.org/json-pretty-print


    I would also suggest using a reactive framework for the javascript such as Vue. Then to simplify the whole textboxes options and the like, use a component framework. (In my case I am using Quasar, but there are others)
     
    jacobpaige likes this.
  17. jacobpaige

    jacobpaige Well-Known Member

    Joined:
    Dec 22, 2015
    Messages:
    10,104
    Likes Received:
    3,732
    Reading List:
    Link
    After getting 99% complete, I'm kinda wishing I'd listened to this piece of advice. I just didn't want to add learning Vue and Quasar on to learning HTML, JavaScript and CSS.

    That said, I was wonder if you know why my select boxes have such tiny, tiny fonts in their dropdown menus, or why there's such a vast difference in performance between IE and Chrome/FF. You can see what I mean here, code here. I looked around and tried everything anyone suggested for the tiny text problem, but I didn't even know where to begin on looking into the IE problem.
     
  18. lnv

    lnv ✪ Well-Known Hypocrite

    Joined:
    Jan 24, 2017
    Messages:
    7,702
    Likes Received:
    9,044
    Reading List:
    Link
    IE sucks, that said, I would avoid using px for font sizes unless you are strictly dictating sizes and use em instead.

    By the way, when working with CSS, use developer tools to modify the css in realtime. Then apply it to the code, saves a lot of time and effort.
     
  19. jacobpaige

    jacobpaige Well-Known Member

    Joined:
    Dec 22, 2015
    Messages:
    10,104
    Likes Received:
    3,732
    Reading List:
    Link
    Arg, that's the problem with using found code. Sometimes you fail to notice that they added px to things ><. I can't believe it was that simple. Thanks for pointing it out :)