get a blog content dynamically using RESTeasy - jax-rs

I am a Java developer, I want to write my own blogging application (that bloggers use to write their blogs with) i know it may sound crazy but i want it just for learning purpose, i am using JSF EJB Hibernate and RESTeasy tools,i started it i have created the database and the view.
From the information that i collected it is recommended to store the blog content in database(in html text), i find that i can use for that Javascript editor like CKEditor after the blogger write his blog in CKEditor i will concatenate it with a prepared header and footer after that i will store it in the database, and i found out that i can get blog post using RESTeasy API.
As an example(sorry):
after the blog is stored in the database
i want to present it to visitors like this:
link containing a path and the id of the article
<div>
Read More...
</div>
when the visitor press the link a REST Controller handle the request, fetch the article from the database using the provided id in the link and return an html page (without creating it statically).
The RESTeasy part perhaps something like this:
#Stateless
#Path("/article/")
public class ArticleResource {
#EJB
private ArticleService articleService;
#GET
#Path("/{id}")
#Produces(value = MediaType.TEXT_HTML)
public Response getArticleById(#PathParam("id") Long id){
//get article post from the database
Article article = articleService.findById(id);
//something here i didn't know
//return article post as an html page
}
}
Please if there is anything here that you see is wrong feel free to inform me, i am just learning here. And if there is an even better approach that you see is good, i really appreciate it.
I know perhaps using Spring it can be better but i want just to learn here how to do it.
I want to know how to get an html page stored in database using JAXRS,
the html page has no file in the application it is just stored in the database something like this:
"<html><head>...</head> <body>...content of the blog here</body> </html>"
Thank you in advance.

Related

Expression Engine to Craft CMS

Hello I've recently migrated a website from EE to Craft using this guide :
https://docs.craftcms.com/feed-me/v4/guides/migrating-from-expressionengine.html
However the migration did not cover blog posts comments, and the client wants the comments for each post migrated as well, could you please advise me how to do that ?
Here is the information from the JSON file (I replaced the text to protect my client privacy )
https://codebeautify.org/jsonviewer/y22cc64b3
As seen in the json there is no comments saved anywhere.
And here is the code from the guide that I used
https://gist.github.com/engram-design/5fbe54ef0abb15e3ff6f667291098464
Please let me know if there is any other way of doing that.

Storing and retrieving data for custom Shopify apps

So I am trying to build something for my store but a few things are somewhat unclear.
If I need to save some user settings do I need my own backend just
for that app specifically? For simplicity sake, I want build an app
to save and display a custom message in cart-template.liquid.To
achieve that, I think my app should make a request to my backend (let
say, on heroku) and save it in some db that app is using?
How do I retrieve that data in cart-template.liquid? I guess I
build a snippet that calls a public endpoint of my backend that
returns that saved message using fetch() or maybe axios.get and
embed it using {% render 'fetch-custom-message-snippet' %} ?
Say I ask for user input, ie. "Engraved message" and the form is in cart-template.liquid,
of course. The following snippet is used:
<p class="line-item-property__field">
<label for="engraved-message">Engraved message</label>
<input id="engraved-message" type="text" name="properties[Engraved message]">
</p>
How do I make sure that bit of information is captured and passed to me? I guess I want to see it somewhere in the order details.
If I need to save some user settings do I need my own backend just for that app specifically? For simplicity sake, I want build an app to save and display a custom message in cart-template.liquid.To achieve that, I think my app should make a request to my backend (let say, on heroku) and save it in some db that app is using?
Yes, you need your own backend. Your application alone is responsible for storing its own information (there are some exceptions like a special order field which I show you below) - that typically infers a database that back ups your service and holds your data. Please check out this thread as you can find lots of valuable information there.
Regarding cart-template.liquid I'd suggest taking a look at the official "Shopify Developers" documentation. All information you're allowed to display and request are neatly explained and ordered there.
How do I retrieve that data in cart-template.liquid? I guess I build a snippet that calls a public endpoint of my backend that returns that saved message using fetch() or maybe axios.get and embed it using {% render 'fetch-custom-message-snippet' %} ?
Once again there are good guides out there. I suggest taking a look at this blog post which goes into in-depth on this topic. Shopify's documentation about the Liquid template language is also highly advised to be read.
How do you retrieve that data? According to this specific example any input will be supplied to your order page in the Shopify admin. For example:
<label for="CartNote">Special instructions</label>
<textarea name="note" id="CartNote">{{ cart.note }}</textarea>
*taken from https://shopify.github.io/liquid-code-examples/example/cart-notes*; shows a Special instruction label and textarea for users to submit details about the oder - you will get this data on, as mentioned, the order page in the Shopify admin.
Say I ask for user input, ie. "Engraved message" and the form is in
cart-template.liquid, of course. The following snippet is used:
[...] How do I make sure that bit of information is captured and passed to me? I guess I want to see it somewhere in the order details.
see above
//EDIT:
To prevent any confusion: It seems like you want to develop a custom app just for personal usage and not to publish it in the Shopify App Store - in this case you most often than not don't need an external database; e.g. the example you provided with a simple order request which is easily doable through Shopify's examples.
For your specific case this code snippet (I modified your original example to fit the case - it's not a full cart-template.liquid obviously; in this case the file is called cart.liquid):
<label for="engraved-message">Engraved message</label>
<textarea name="message" id="engraved-message">{{ cart.note }}</textarea>
//EDIT 2:
The link - shared by another user in this thread, namely #Simas Butavičius - is actually kind of useful if you have problems with the customization process in general, i.e. if you want to revise some basic concepts or want to check how to implement the code snippet from above in the whole structure of your website I'd advise to skim through this site.
Needless to say, there are hundreds of good tutorials, questions regarding the same "issue" or other resources in general.
I suggest for further reading purposes to check out some of these links and guides (some may be mentioned above):
https://shopify.github.io/liquid-code-examples/example/cart-notes
https://shopify.github.io/liquid-code-examples/example/checkout-form (! very good in-depth example)
https://www.christhefreelancer.com/shopify-liquid-guide/
https://shopify.dev/docs/themes/theme-templates/cart-liquid
https://shopify.dev/docs/themes/liquid/reference
https://www.shopify.com/partners/shopify-cheat-sheet (! helpful cheatsheet)
https://community.shopify.com/c/Shopify-Design/Cart-Use-cart-attributes-to-collect-more-information/td-p/613718
https://community.shopify.com/c/Shopify-APIs-SDKs/Add-custom-input-fields-to-cart/td-p/154710
https://community.shopify.com/c/Shopify-Design/Product-pages-Get-customization-information-for-products/td-p/616503
Here is the tutorial specifically for creating custom shopify input field for getting engraving information: https://community.shopify.com/c/Shopify-Design/Product-pages-Get-customization-information-for-products/td-p/616503

How to handle multiple title url for seo

I am having multiple list of classes in my application. I'm trying to re-write a URL to every class for seo purpose dynamically.
Here is the rewrite url pattern:
Class title: Web developer with angular
Url: https://www.example.com/web-developer-with-angular
Everything is working fine if I doesn't have duplicate class names. If I got duplicate class names content going wrong.
How can I resolve this duplicate url issues. Can anyone help me?
Can I use titles like below for seo:
Class title-1: Web developer with angular
Url: https://www.example.com/web-developer-with-angular
Class title-2: Web developer with angular
Url: https://www.example.com/web-developer-with-angular-1
Class title-3: Web developer with angular
Url: https://www.example.com/web-developer-with-angular-2
Can anyone tell me, Is this pattern good for seo or not? Or Shall I need to maintain different titles?
Which is better for seo? Please help me and thanks for advance.
You should definitely keep different titles. /angular-web-developer, /freelance-web-developer, /professional-web-developer, and so on. The URL should reflect the contents of the webpage. For example, If the content of the webpage talks about a freelance Angular web developer, the URL should be something like : /freelance-angular-web-developer. A good starting point is to do a little keyword research using Ubbersuggest or Google analytics.

Pulling data, mainly text from websites

I'm fairly new to programming in general but I have delved into vb.net recently. I was looking into how to grab data from a website but don't fully comprehend how to or through what means.
My main end game is to just pull data for a lack of better word. Say for instance, a website shows text, I'd like to be able to pull that text into my program using vb.net. Is that possible?
I don't know how to use javascript, php and know only little of html/css. I'm of course willing to learn but I haven't had much luck searching for this specific information or solution. Without access to the websites database, is there another way for my app to read the website for what it would be displaying and retrieve this information? I'm mainly concerned with text, no other information is really needed. From what i've gathered, the information is tagged by something like an ID, or class? Any help would be appreciated.
Web servers essentially have 2 operations, POST, which is you sending something to the website, and GET, which is you requesting something from the website.
For the most part you can just do a GET of some sort on the website and it'll return what you request in a data format, likely JSON. You can often look for fields based on CSS selectors in the web page itself. Though, there are other ways and some HTTP libraries may return the data to you in various formats, mainly JSON and XML.
I'd suggest right click->view source on a web page to learn more about how they're structured. As for how to do a GET in javascript on some website, this code would grab the website at the URL you give it.
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); //the get request
xmlHttp.send( null );
return xmlHttp.responseText; //the website data in XML format.
}

dojo ajax dropdownlist

I am trying to set a web application using ajax dojo technology. For this I need an exemple showing how to send and receive data with dojo library.I use also J2ee in my project.
Please if you have a constructive example show it to me.
Client side: JSP with ajax dojo its purpose is to send a selected item to the server side.
Server side:Servlet catch the data sent and construct sql query with it finally send it again to jsp
JSP receive the result of the query (xml file)
dojo construct the seceond dropdownlist automaticallt.
Just i need an exemple of send and receive.
Many Thinks.
Have you looked on Dojo's website? From your question, it sounds like what you want is dojo.data.ItemFileReadStore. The Dojo website has many examples of the uses of ItemFileReadStore, including one in which one FilteringSelect is dependently linked to another, which seems to be what you describe.
As to your request for examples of send and receive in JSP: a Google search for JSP tutorial turns up a site called jsptut.com as the first result. Have you looked there?