postype_rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +3 -0
- data/Rakefile +4 -0
- data/lib/postype_rails/uploader.rb +142 -0
- data/lib/postype_rails/version.rb +5 -0
- data/lib/postype_rails.rb +21 -0
- data/postype_rails.gemspec +42 -0
- data/sig/postype_rails.rbs +4 -0
- metadata +56 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b7b7c62d437ecc22b1db2f847b0701adb642534bfbef810ed2b66d47c919d96b
|
4
|
+
data.tar.gz: 846e428a6ce3cd90172ef1a6c9cc6af27abaef3fe0e378addea9b9466bc7710f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a9f148d570b7806ad6f95ba7a98afa24635c7c2a48ef89a72e75c19209d30b19539ef22d8558f4abe1b9f6a82f655d07b02daa7d7323ce25ed0f2248d61662a3
|
7
|
+
data.tar.gz: 8a14da1a9843e6a7686aac61212a4d3524fd6082d934d4acb05803645b7119569fba5cf7796342cbbe8264004eb643aa1512548e19170a3452aa7029ab4ed1b5
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 shinyo17
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Uploader
|
5
|
+
def initialize(cookie, blog_id, title, content)
|
6
|
+
@cookie = cookie
|
7
|
+
@blog_id = blog_id
|
8
|
+
@title = title
|
9
|
+
@content = content
|
10
|
+
end
|
11
|
+
|
12
|
+
def upload
|
13
|
+
@post_id = posting
|
14
|
+
saving
|
15
|
+
publish
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def posting
|
21
|
+
uri = URI('https://www.postype.com/api/post/id')
|
22
|
+
params = {
|
23
|
+
:blog_id => @blog_id,
|
24
|
+
}
|
25
|
+
uri.query = URI.encode_www_form(params)
|
26
|
+
|
27
|
+
req = Net::HTTP::Get.new(uri)
|
28
|
+
req['authority'] = 'www.postype.com'
|
29
|
+
req['accept'] = 'application/json, text/javascript, */*; q=0.01'
|
30
|
+
req['accept-language'] = 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7'
|
31
|
+
req['cookie'] = @cookie
|
32
|
+
req['sec-ch-ua'] = '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"'
|
33
|
+
req['sec-ch-ua-mobile'] = '?1'
|
34
|
+
req['sec-ch-ua-platform'] = '"Android"'
|
35
|
+
req['sec-fetch-dest'] = 'empty'
|
36
|
+
req['sec-fetch-mode'] = 'cors'
|
37
|
+
req['sec-fetch-site'] = 'same-origin'
|
38
|
+
req['user-agent'] = 'Mozilla/5.0 (Linux; Android 13; SM-G981B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Mobile Safari/537.36'
|
39
|
+
req['x-requested-with'] = 'XMLHttpRequest'
|
40
|
+
|
41
|
+
req_options = {
|
42
|
+
use_ssl: uri.scheme == 'https'
|
43
|
+
}
|
44
|
+
|
45
|
+
res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
46
|
+
http.request(req)
|
47
|
+
end
|
48
|
+
|
49
|
+
JSON.parse(res.body)["data"]["post_id"]
|
50
|
+
end
|
51
|
+
|
52
|
+
def saving
|
53
|
+
uri = URI('https://www.postype.com/api/post/save')
|
54
|
+
params = {
|
55
|
+
:auto => '0',
|
56
|
+
}
|
57
|
+
uri.query = URI.encode_www_form(params)
|
58
|
+
|
59
|
+
req = Net::HTTP::Post.new(uri)
|
60
|
+
req.content_type = 'application/x-www-form-urlencoded; charset=UTF-8'
|
61
|
+
req['authority'] = 'www.postype.com'
|
62
|
+
req['accept'] = 'application/json, text/javascript, */*; q=0.01'
|
63
|
+
req['accept-language'] = 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7'
|
64
|
+
req['cookie'] = @cookie
|
65
|
+
req['origin'] = 'https://www.postype.com'
|
66
|
+
req['sec-ch-ua'] = '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"'
|
67
|
+
req['sec-ch-ua-mobile'] = '?1'
|
68
|
+
req['sec-ch-ua-platform'] = '"Android"'
|
69
|
+
req['sec-fetch-dest'] = 'empty'
|
70
|
+
req['sec-fetch-mode'] = 'cors'
|
71
|
+
req['sec-fetch-site'] = 'same-origin'
|
72
|
+
req['user-agent'] = 'Mozilla/5.0 (Linux; Android 13; SM-G981B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Mobile Safari/537.36'
|
73
|
+
req['x-requested-with'] = 'XMLHttpRequest'
|
74
|
+
|
75
|
+
req.set_form_data({
|
76
|
+
'characters_limit' => '100000',
|
77
|
+
'post_id' => @post_id,
|
78
|
+
'content' => @content,
|
79
|
+
'blog_id' => '1403904',
|
80
|
+
'auto_save' => '1',
|
81
|
+
'default_font' => 'font-sans-serif',
|
82
|
+
'default_align' => 'text-left',
|
83
|
+
'use_indent' => '',
|
84
|
+
'use_p_margin' => '1',
|
85
|
+
'type' => 'normal',
|
86
|
+
'video-file-id' => '',
|
87
|
+
'video-thumbnail-file-id' => '',
|
88
|
+
'title' => @title,
|
89
|
+
'sub_title' => ''
|
90
|
+
})
|
91
|
+
|
92
|
+
req_options = {
|
93
|
+
use_ssl: uri.scheme == 'https'
|
94
|
+
}
|
95
|
+
|
96
|
+
Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
97
|
+
http.request(req)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def publish
|
102
|
+
uri = URI('https://www.postype.com/api/post/publish')
|
103
|
+
req = Net::HTTP::Post.new(uri)
|
104
|
+
req.content_type = 'application/x-www-form-urlencoded; charset=UTF-8'
|
105
|
+
req['authority'] = 'www.postype.com'
|
106
|
+
req['accept'] = '*/*'
|
107
|
+
req['accept-language'] = 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7'
|
108
|
+
req['cookie'] = @cookie
|
109
|
+
req['origin'] = 'https://www.postype.com'
|
110
|
+
req['sec-ch-ua'] = '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"'
|
111
|
+
req['sec-ch-ua-mobile'] = '?1'
|
112
|
+
req['sec-ch-ua-platform'] = '"Android"'
|
113
|
+
req['sec-fetch-dest'] = 'empty'
|
114
|
+
req['sec-fetch-mode'] = 'cors'
|
115
|
+
req['sec-fetch-site'] = 'same-origin'
|
116
|
+
req['user-agent'] = 'Mozilla/5.0 (Linux; Android 13; SM-G981B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Mobile Safari/537.36'
|
117
|
+
req['x-requested-with'] = 'XMLHttpRequest'
|
118
|
+
|
119
|
+
req.set_form_data({
|
120
|
+
'post_id' => @post_id,
|
121
|
+
'file_id' => '',
|
122
|
+
'status' => 'published',
|
123
|
+
'hidden_input' => '',
|
124
|
+
'category_id' => '',
|
125
|
+
'tags' => '',
|
126
|
+
'public_option' => 'public',
|
127
|
+
'point' => '1000',
|
128
|
+
'free_blog_membership_plan_id' => '',
|
129
|
+
'comment_type' => 'all_secret',
|
130
|
+
'pubdate' => 'retain',
|
131
|
+
'pubdate_time' => ''
|
132
|
+
})
|
133
|
+
|
134
|
+
req_options = {
|
135
|
+
use_ssl: uri.scheme == 'https'
|
136
|
+
}
|
137
|
+
|
138
|
+
Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
139
|
+
http.request(req)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "postype_rails/uploader"
|
4
|
+
|
5
|
+
class PostypeRails
|
6
|
+
# Upload post in postype
|
7
|
+
#
|
8
|
+
# Example:
|
9
|
+
# >> PostypeRails.upload("cookie", "blog_id", "my post title", "<p>my post content</p>")
|
10
|
+
# => #<Net::HTTPOK 200 OK readbody=true>
|
11
|
+
#
|
12
|
+
# Arguments:
|
13
|
+
# cookie: (String)
|
14
|
+
# blog_id: (String)
|
15
|
+
# title: (String)
|
16
|
+
# content: (String)
|
17
|
+
def self.upload(cookie, blog_id, title, content)
|
18
|
+
uploader = Uploader.new(cookie, blog_id, title, content)
|
19
|
+
uploader.upload
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/postype_rails/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "postype_rails"
|
7
|
+
spec.version = PostypeRails::VERSION
|
8
|
+
spec.authors = ["shinyo17"]
|
9
|
+
spec.email = ["17shinyo17@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Upload post in postype"
|
12
|
+
spec.description = "PostypeRails can help you automate when you post in your Postype Blog."
|
13
|
+
spec.homepage = "https://github.com/keepwa1king/postype_rails"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
spec.metadata["allowed_push_host"] = 'https://rubygems.org/'
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/keepwa1king/postype_rails"
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/keepwa1king/postype_rails/CHANGELOG.md"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(__dir__) do
|
26
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
spec.files += ["lib/postype_rails.rb", "lib/postype_rails/uploader.rb"]
|
32
|
+
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
# Uncomment to register a new dependency of your gem
|
38
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
39
|
+
|
40
|
+
# For more information and examples about making a new gem, check out our
|
41
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: postype_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- shinyo17
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-11-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: PostypeRails can help you automate when you post in your Postype Blog.
|
14
|
+
email:
|
15
|
+
- 17shinyo17@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- Gemfile
|
21
|
+
- LICENSE.txt
|
22
|
+
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- lib/postype_rails.rb
|
25
|
+
- lib/postype_rails/uploader.rb
|
26
|
+
- lib/postype_rails/version.rb
|
27
|
+
- postype_rails.gemspec
|
28
|
+
- sig/postype_rails.rbs
|
29
|
+
homepage: https://github.com/keepwa1king/postype_rails
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
metadata:
|
33
|
+
allowed_push_host: https://rubygems.org/
|
34
|
+
homepage_uri: https://github.com/keepwa1king/postype_rails
|
35
|
+
source_code_uri: https://github.com/keepwa1king/postype_rails
|
36
|
+
changelog_uri: https://github.com/keepwa1king/postype_rails/CHANGELOG.md
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.6.0
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubygems_version: 3.3.7
|
53
|
+
signing_key:
|
54
|
+
specification_version: 4
|
55
|
+
summary: Upload post in postype
|
56
|
+
test_files: []
|