Giter VIP home page Giter VIP logo

tamiragun / doc2blog Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 519 KB

As a graduate project for our HyperionDev bootcamp, we had to build a blog deadlines and file upload system. We used Java, Spring Boot, PostgreSQL, JWT authentication, Swagger, React, Bootstrap, and Heroku.

Home Page: https://doc2blog.herokuapp.com/

Java 43.68% Shell 0.02% HTML 1.96% CSS 5.08% JavaScript 49.25%
java spring-boot react react-router jwt-authentication postgresql postgresql-database heroku-deployment heroku api-rest spring-data-jpa spring-security swagger swagger-ui maven bootstrap

doc2blog's Introduction

Doc2Blog

Introduction

As part of the HyperionDev graduate programme, we were asked to work a paired project. The brief called for an app that allows bloggers to keep track of their deadlines and upload blogposts as Word documents. It performs a basic spell check and also converts the post to HTML, ready to be published to the web.

How to use this app

Navigate to https://doc2blog.herokuapp.com/ to see this app in action. Follow the below steps, or watch this video, to see how it works:

Logging in

  • Create a profile by clicking "register".
  • Log in with that profile
  • Navigate to "Blog posts" in the navigation menu.

Deadlines and reminders

  • You can add blog post deadlines by clicking the "Add new deadline" button.
  • Enter the topic and due date of your upcoming blogpost. You can also select if it is a recurring blog topic, or just a once-off.
  • Set how far in advance you want to be reminded of your deadline, and how often you want those reminders to recur.
  • Upon submit, your blog post deadline will appear in the table.
  • To upload the corresponding post, click "upload draft".
  • Once your draft is uploaded and published, you can click "mark published" next to the corresponding post, which removes that deadline from the table.
  • Closer to the date, reminders will start popping up at the top of the page. Simply acknowledge them, and they will vanish.
  • If you have set reminders to recur, they will only pop up again at the indicated interval, and if you have acknowledged the previous reminder.
  • If your post is already behind on the due date, it will show up as red in the table.

Uploading a blog post

  • Click "upload draft" or navigate to "publish post" in the navigation menu, and follow the stepper:
  • Use the form to select a document from your computer. It has to be a Word or Open Format document. CLick next.
  • Select what style you would like your published post to have. Click next. Tip: You can read up about the different styleguide, as well as tips for your post, by navigating to the Style guide in the navigation menu.
  • Click "Preview spell checked post", which opens your post in a new tab. The stylesheet won't be applied here yet, but you will see spelling errors highlighted in yellow.
  • Close the tab and/or go back to the previous Doc2Bog tab you had open. You can either click "Back" to upload a new version of your blog post without those errors. Or you can click "Next" to proceed with publication.
  • You are now published! Click on "View your blog post live" to see your blog post, styled, and public.
  • CLick "Next" to go back to the overview of your deadlines.
  • Mark your topic as published.
  • Write a new blog post!

How to install this project

To install and run this programme on your local computer, you will need PostgreSQL, JDE and JRE 17, Maven, Git, Npm, and Node.js.

  1. Clone the repository to your local computer.
  2. Navigate to the directory where you saved the repository.
  3. Inside the repository, start a terminal window.
  4. Type mvn install and wait for the process to run.
  5. Create a database in PostgreSQL.
  6. Add a user to that database and grant it all privileges on the database.
  7. In your project folder, go to the config folder and create a new file called application.properties (no other suffix).
  8. In that file, paste the contents of the application.properties.example file which is located in the same folder.
  9. In your newly created config/application.properties file, adapt the database connections to your new database, username, and password.
  10. Uncomment the line that says spring.datasource.initialization-mode=always.
  11. In the terminal window where you ran mvn install, now type git init. This creates a Git repository.
  12. A file called '.gitignore' will have been created in the root of your project folder. Open it and paste in it /config/* and on the next line !/config/*.example. This ensures that your database passwords are not published to GitHub, i.e. the world.
  13. Run the programme from within your IDE to start up the server.
  14. In the terminal window, navigate to the src/client folder within your project.
  15. Type npm install and wait for the process to run.
  16. Now type npm start and wait for your browser to open a new window.
  17. Go back to the /config/application.properties file and comment out the spring.datasource.initialization-mode=always again. The script should have done its job and this line is no longer necessary unless you connect a new database.
  18. You should now be able to use the app on your localhost browser window!
  19. If you ever want to deploy this app, you'll first need to run mvn clean install in the terminal window in your project directory. This ensures that the frontend is built and then stored in the server's resources folder.

Documentation

Resources used

Several of the technologies and frameworks used in this app were new to us, so we got a little help from our friends over at Stackoverflow and Medium. A few special shout-outs:

Acceptance criteria

This brief was provided by the fictional 'client', a group of journalists:

"We have observed that despite the availability of content management systems, many of them have still not addressed some of the problems faced in periodic publishing. Some of these problems concern deadlines, grammaticality, customisation, accessibility and discoverability. To help improve the situation, we would like you to publish blog articles.

A lot more people are far more comfortable using a specialised word processor than the built-in word processor included in mainstream content management systems. Most word processors currently can produce documents in Word (DOCX) and OpenDocument Format (ODF). We would like you to allow bloggers to be able to submit OpenDocument and Word documents and publish them as web articles that can be viewed in the browser. If the documents contain hyperlinks to resources that can be embedded in the articles, you may safely embed the resources in the published article.

To ensure that bloggers stay on their respective schedules, we would like you to allow them to set regular deadlines for submitting their articles. They should also be able to set their how much time before the deadline they need to be reminded to submit their documents. They can also set multiple reminders. However, each reminder would require acknowledgement from the blogger before firing the next reminder if they have not yet submitted. If they miss a deadline, you may give them a friendly reminder that they have missed the deadline for their submission. Late submissions should be recognised as such.

You can safely assume that the audiences will most likely belong to the Commonwealth and thus be universally most comfortable with British English. To that end, we would like you to perform rudimentary spelling corrections and basic grammar checks upon submission. The blogger can simply be informed of a spelling correction and be required to rectify the grammatical errors. Once the grammatical errors are resolved, they can resubmit and the spellings will be corrected. For example, ‘analyze’ would be corrected to ‘analyse’.

Screen readers used by the blind should be to read your articles. That means we expect to use semantic HTML and other accessibility techniques. We also expect you to provide access to an up-to-date sitemap, RSS feed and metadata using RDF or other metadata frameworks for improved discoverability and accessibility. We would like you to provide stylesheets that the bloggers may reuse and documentation on the elements to select to define their own custom stylesheets. We would also like you to include guidelines on accessibility for the stylesheets and ensure that the stylesheets you provide are conformant."

doc2blog's People

Contributors

tamiragun avatar warren-bradley avatar

Watchers

 avatar

Forkers

floatingreels

doc2blog's Issues

Update state when logged out

Currently, when a token is received, the component's state is set as logged in. But after the token expires, this is not undone. How to deal with logged out status?

And with refresh tokens?

Allow user to choose stylesheet

When the file is uploaded, another field should also be passed with the HTTP request. This is either "basic-stylesheet", "bold-stylesheet", or "sleek-stylesheet".

  • If basic: add no stylesheet to the HTML string that will be written to the file
  • If bold: add Bootstrap CDN link to in the HTML string: <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
  • If sleek: add custom CSS link to in the HTML string: <link href="./sleek-stylesheet.css" rel="stylesheet">
  • TBC the relative path for the custom stylesheet

Add authentication to enable registration and login

  • Add users table
  • Enable registration form to create user (with email validation)
  • Enable login form to obtain JWT token
  • Store JWT token in session storage and apply access restrictions across FE pages
  • Link users to deadlines and reminders to be displayed

Handle validations on file format

Validations:

  • Size (already implemented, but can be revised)
  • Filetype .docx or opensource - validate on frontend or backend? Research best option first
  • Other validations?

Not all deadlines should have reminders

Enable the functionality that allows the user to choose when a reminder should be given, and introduce functionality on the GET request to check for that against the current date.

Improve nav bar UX

  • Use Navlink to show which page the user is on
  • use navigate() to route between routes instead of reloading the page

Further UX improvements

  • Add back and home navigation on each page
  • Style the validation alert upon file upload
  • Give message when user has successfully registered, and tell them to log in

Further security improvements

  • On the registration API, don't return the user (exposes password), but just the response object with .error, .error_message, and perhaps .name.
  • Change "secret" token
  • Look into refresh token

Styling refactors

  • Refactor Card.Header headers to as="h4" in blogpost stepper component
  • Refactor px to rem

Make reminders text dynamic

Currently, the reminders text is

  • called reminder, which is confusing. Let's rename it to reminderText
  • static: it is in the present tense, which doesn't make sense for overdue blog posts
  • could possibly be generated dynamically on the front end (based on the other fields) instead of being stored in the database.

Registration UX

  • Upon registration, display a success message telling the user to log in now
  • After logging in, send them to home and not "navigate(-1)"

Generate link to uploaded file

Upon successful upload, have the API return the file name (instead of "File Received", so that the client can generate a success message containing a hyperlink to the GET endpoint with the newly created file. Now they can see their new post live on the website.

Error handling - FE

  • Add error handling to Deadlines, BlogPost, Reminders and all components with an API call
  • Add user-friendly error handling if there is already an existing user in the database
  • Add error handling when user accesses unknown page

Make sitemap and RSS responsive

The sitemap and RSS feeds are currently static and manual.

Make some javascript script and include it in pre-build scripts, so that these can update themselves automatically.

Unparseable date bug on create blog

The blog POST endpoint is working (as in, no HTTP errors are given and the database is updating and the front end can continue unhampered, but the server is throwing this error:

java.text.ParseException: Unparseable date: "2022-02-14"
	at java.base/java.text.DateFormat.parse(DateFormat.java:399)
	at com.ProjTeam.Doc2Blog.blogPosts.BlogPostController.getBlogPosts(BlogPostController.java:62)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)

Styling of UI

  • Style overdue blogposts as such
  • Add fields in new deadline form

Order blog and reminders GET by date

Currently, the blog deadlines and reminders are ordered in order of creation date. However it makes more sense for them to e ordered by due date in the bloggers' context.

Past deadlines should show up as such

If the deadlines has passed, it should show up as such.
FE can do so based on a field on the BlogPost object: add column in DB and/or add check upon GET request?

Update overdue state in database

Currently, calling the GET request on blogposts returns the list of blogposts and sets the overdue state to true or false based on the current date.

However the underlying database is not being updated. It still says "false" for all blog posts overdue state.

Refactor how blogs are being published

  • Make link between post being published on FE and publish status in DB
  • Change how published posts are being saved: to DB instead of file system? Using components instead of URL? TBC

Refactor routes on FE

  • Refactor how "add post" is being displayed - using routes instead of state
  • Use navigate on menu items

Look into api response format

Client is expecting the response object in JSON format, Spring's ResponseEntity is sending a string. Research how to address this, should it become necessary (e.g. when we need the filename back).

Display link to published HTML post

Once the post has been succesfully "Published", display a link so the user can visit that page. The url will be generated based on the "fileName" that the server responds to the client after handling the file upload.

Static files not showing up in browser

Calling this url from the browser: http://localhost:8080/check?fileName=Testdoc
Gives this error message: https://gyazo.com/196f9fbef6a3a7129456453bdc66cf72
Same for this URL: http://localhost:8080/convert?fileName=Testdoc
I think it might have something to do with access rights to server files?

Also, the XML and RSS files are not showing. Should it be in the static folder of the server instead of the public folder in the client?

Lastly, how do we get access to the stylesheet in the static folder? Can we make an exception for this resource?

  • Convert
  • Spell check
  • Sleek Stylesheet
  • Sitemap
  • RSS feed

Allow reminders to know overdue state

The front end needs to be able to give a pop-up when a deadline is overdue.

Since the reminders table is linked to the blogpost table, can you persist the overdue state from the blogpost into its reminders? that way, I can style the overdue reminders differently to the pre-due reminders

Create entities, repositories and controller for projects and reminders

Entities:

  • projects
  • reminders

Repositories:

  • projects
  • reminders

Controller:

  • one controller for both?
  • endpoints:
    • GET: returns all unpublished projects + returns all unacknowledged reminders belonging to above projects
    • POST: creates a new project based on HTTP body + creates reminder(s) based on same body
    • PUT: updates the given project to "published"
    • PUT: updates the given reminder to "acknowledged"

Front end validation

  • When adding new post, deadline should not be in the past
  • Validate for email address on register?
  • Validate for password on register?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.