diff --git a/README.md b/README.md index c27261def..41b3cce62 100644 --- a/README.md +++ b/README.md @@ -218,8 +218,11 @@ _**All `i18n` contributions are welcome to `i18n` [branch](https://github.com/li 📦 **Add-ons**: Official add-ons for Postwoman. - - **[Postwoman Proxy β](https://github.com/postwoman-io/postwoman-proxy)** - A simple proxy server created for Postwoman - - **[Postwoman CLI β](https://github.com/postwoman-io/postwoman-cli)** - A CLI solution for Postwoman + - **[Proxy β](https://github.com/postwoman-io/postwoman-proxy)** - A simple proxy server created for Postwoman + - **[CLI β](https://github.com/postwoman-io/postwoman-cli)** - A CLI solution for Postwoman + - **[Browser Extensions](https://github.com/AndrewBastin/postwoman-firefox)** - Browser extensions that simplifies access to Postwoman + + > [![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_16x16.png) **Firefox**](https://addons.mozilla.org/en-US/firefox/addon/postwoman)  |  ![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_16x16.png) **Chrome (coming soon)** _Add-ons are developed and maintained under **[Official Postwoman Organization](https://github.com/postwoman-io)**_ diff --git a/components/collections/addCollection.vue b/components/collections/addCollection.vue index 2c68f630f..2789a52d7 100644 --- a/components/collections/addCollection.vue +++ b/components/collections/addCollection.vue @@ -4,7 +4,7 @@

- History is empty + {{ $t("history_empty") }}

@@ -174,23 +176,23 @@ @click="enableHistoryClearing" > clear_all - Clear All + {{ $t("clear_all") }} -
- +
@@ -247,7 +251,7 @@ class="icon" id="reject-clear-history-button" @click="disableHistoryClearing" - v-tooltip="'No'" + v-tooltip="$t('no')" > close @@ -371,7 +375,7 @@ export default { this.filterText = ""; this.disableHistoryClearing(); updateOnLocalStorage("history", this.history); - this.$toast.error("History Deleted", { + this.$toast.error(this.$t("history_deleted"), { icon: "delete" }); }, @@ -392,7 +396,7 @@ export default { this.filterText = ""; } updateOnLocalStorage("history", this.history); - this.$toast.error("Deleted", { + this.$toast.error(this.$t("deleted"), { icon: "delete" }); }, diff --git a/functions/network.js b/functions/network.js new file mode 100644 index 000000000..7ed233cf8 --- /dev/null +++ b/functions/network.js @@ -0,0 +1,24 @@ +import AxiosStrategy from "./strategies/AxiosStrategy"; +import ProxyStrategy from "./strategies/ProxyStrategy"; +import FirefoxStrategy from "./strategies/FirefoxStrategy"; + + +const runAppropriateStrategy = (req, store) => { + // The firefox plugin injects a function to send requests through it + // If that is available, then we can use the FirefoxStrategy + if (window.firefoxExtSendRequest) { + return FirefoxStrategy(req, store); + } + + if (store.state.postwoman.settings.PROXY_ENABLED) { + return ProxyStrategy(req, store); + } + + return AxiosStrategy(req, store); +} + +const sendNetworkRequest = (req, store) => + runAppropriateStrategy(req, store) + .finally(() => window.$nuxt.$loading.finish()); + +export { sendNetworkRequest }; diff --git a/functions/strategies/AxiosStrategy.js b/functions/strategies/AxiosStrategy.js new file mode 100644 index 000000000..9bef30aef --- /dev/null +++ b/functions/strategies/AxiosStrategy.js @@ -0,0 +1,8 @@ +import axios from "axios"; + +const axiosStrategy = async (req, _store) => { + const res = await axios(req); + return res; +}; + +export default axiosStrategy; diff --git a/functions/strategies/FirefoxStrategy.js b/functions/strategies/FirefoxStrategy.js new file mode 100644 index 000000000..77b15f453 --- /dev/null +++ b/functions/strategies/FirefoxStrategy.js @@ -0,0 +1,15 @@ +const firefoxStrategy = (req, _store) => new Promise((resolve, reject) => { + + const eventListener = (event) => { + window.removeEventListener("firefoxExtSendRequestComplete", eventListener); + + if (event.detail.error) reject(JSON.parse(event.detail.error)); + else resolve(JSON.parse(event.detail.response)); + }; + + window.addEventListener("firefoxExtSendRequestComplete", eventListener); + + window.firefoxExtSendRequest(req); +}); + +export default firefoxStrategy; diff --git a/functions/strategies/ProxyStrategy.js b/functions/strategies/ProxyStrategy.js new file mode 100644 index 000000000..0b6f50b0f --- /dev/null +++ b/functions/strategies/ProxyStrategy.js @@ -0,0 +1,12 @@ +import axios from "axios"; + +const proxyStrategy = async (req, store) => { + const { data } = await axios.post( + store.state.postwoman.settings.PROXY_URL || + "https://postwoman.apollotv.xyz/", + req + ); + return data; +}; + +export default proxyStrategy; diff --git a/lang/en-US.js b/lang/en-US.js index 9ad7e21a1..906fb0602 100644 --- a/lang/en-US.js +++ b/lang/en-US.js @@ -106,5 +106,148 @@ export default { client_id: "Client ID", scope: "Scope", state: "State", - token_req_list: "Token Request List" + token_req_list: "Token Request List", + no_path: "No path", + no_label: "No label", + prerequest_script: "Pre-Request Script", + no_prerequest_script: "No pre-request script", + search_history: "search history", + history_empty: "History is empty", + history_deleted: "History Deleted", + clear: "Clear", + clear_all: "Clear All", + cleared: "Cleared", + close: "Close", + sort: "Sort", + time: "Time", + duration: "Duration", + no_duration: "No duration", + show_more: "Show more", + hide_more: "Hide more", + collection: "Collection", + current_collection: "Current Collection", + select_collection: "Select a Collection", + create_collection: "Create a Collection", + new: "New", + import_export: "Import / Export", + more: "More", + folder: "Folder", + new_folder: "New Folder", + my_new_folder: "My New Folder", + folder_empty: "Folder is empty", + edit_folder: "Edit Folder", + edit: "Edit", + delete: "Delete", + deleted: "Deleted", + undo: "Undo", + collection_empty: "Collection is empty", + new_collection: "New Collection", + my_new_collection: "My New Collection", + edit_collection: "Edit Collection", + edit_request: "Edit Request", + save_request_as: "Save Request As", + export: "Export", + connecting_to: "Connecting to {name}...", + connected: "Connected", + connected_to: "Connected to {name}", + disconnected: "Disconnected", + disconnected_from: "Disconnected from {name}", + something_went_wrong: "Something went wrong!", + error_occurred: "An error has occurred.", + browser_support_sse: + "This browser doesn't seems to have Server Sent Events support.", + log: "Log", + no_url: "No URL", + run_query: "Run Query", + copy_query: "Copy Query", + kinda_dark: "Kinda Dark", + clearly_white: "Clearly White", + just_black: "Just Black", + auto_system: "Auth (system)", + green: "Green", + yellow: "Yellow", + pink: "Pink", + red: "Red", + purple: "Purple", + orange: "Orange", + cyan: "Cyan", + blue: "Blue", + loading: "Loading...", + fetching: "Fetching...", + waiting_send_req: "(waiting to send request)", + cancel: "Cancel", + save: "Save", + dismiss: "Dismiss", + are_you_sure: "Are you sure?", + yes: "Yes", + no: "No", + restore: "Restore", + add_star: "Add star", + remove_star: "Remove star", + nothing_found: "Nothing found", + replace_current: "Replace current", + replace_json: "Replace with JSON", + preserve_current: "Preserve current", + import_json: "Import from JSON", + download_file: "Download file", + upload_file: "Upload file", + copy_response: "Copy response", + copy_code: "Copy code", + copy_schema: "Copy Schema", + use_request: "Use request", + documentation: "Documentation", + docs: "Docs", + reset_default: "Reset to default", + fields: "FIELDS", + deprecated: "DEPRECATED", + add_one_header: "(add at least one header)", + add_one_parameter: "(add at least one parameter)", + header_count: "header {count}", + parameter_count: "parameter {count}", + variable_count: "variable {count}", + value_count: "value {count}", + send_request_first: "Send a request first", + generate_docs: "Generate Documentation", + generate_docs_message: + "Import any Postwoman Collection to Generate Documentation on-the-go.", + generate_docs_first: "Generate documentation first", + docs_generated: "Documentation generated", + import_collections: "Import collections", + optional: "(optional)", + json: "JSON", + none: "None", + username: "Username", + password: "Password", + token: "Token", + payload: "Payload", + choose_file: "Choose a file", + file_imported: "File imported", + f12_details: "(F12 for details)", + we_use_cookies: "We use cookies", + copied_to_clipboard: "Copied to clipboard", + finished_in: "Finished in {duration}ms", + check_console_details: "Check console for details.", + download_started: "Download started", + url_invalid_format: "URL is not formatted properly", + curl_invalid_format: "cURL is not formatted properly", + enable_proxy: "Try enabling Proxy", + complete_config_urls: "Please complete configuration urls.", + token_request_saved: "Token request saved", + donate_info1: + "If you have enjoyed the productivity of using Postwoman, consider donating as a sign of appreciation.", + donate_info2: + "You can support Postwoman development via the following methods:", + one_time_recurring: "One-time or recurring", + one_time: "One-time", + recurring: "Recurring", + wiki: "Wiki", + error: "Error", + go_home: "Go Home", + reload: "Reload", + enter_curl: "Enter cURL", + empty: "Empty", + extensions: "Extensions", + extensions_info1: "Browser extension that simplifies access to Postwoman", + extensions_info2: "Get Postwoman browser extension!", + installed: "Installed" }; diff --git a/layouts/default.vue b/layouts/default.vue index 30e0d494b..447e58ae4 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -12,7 +12,7 @@ :to="localePath('index')" :class="linkActive('/')" v-tooltip.right="$t('home')" - aria-label="Home" + :aria-label="$t('home')" > @@ -27,7 +27,7 @@ :to="localePath('graphql')" :class="linkActive('/graphql')" v-tooltip.right="$t('graphql')" - aria-label="GraphQL" + :aria-label="$t('graphql')" > books @@ -150,7 +150,7 @@ :to="localePath('settings')" :class="linkActive('/settings')" v-tooltip.right="$t('settings')" - aria-label="Settings" + :aria-label="$t('settings')" > settings @@ -289,10 +289,20 @@ offline_bolt -