repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
shirasagi/opendata | app/controllers/opendata/agents/pages/app/app_controller.rb | class Opendata::Agents::Pages::App::AppController < ApplicationController
include Cms::PageFilter::View
helper Opendata::UrlHelper
public
def index
@cur_node = @cur_page.parent.becomes_with_route
@cur_page.layout_id = @cur_node.page_layout_id || @cur_node.layout_id
@search_path = view_cont... |
shirasagi/opendata | lib/voice/text_to_speech_factory.rb | <reponame>shirasagi/opendata
class Voice::TextToSpeechFactory
class << self
public
def create(type, config = {})
Voice::OpenJtalk.new(config)
end
end
end
|
shirasagi/opendata | spec/models/cms/site_spec.rb | require 'spec_helper'
describe Cms::Site do
subject(:model) { Cms::Site }
subject(:factory) { :ss_site }
it_behaves_like "mongoid#save"
it_behaves_like "mongoid#find"
describe "#attributes" do
subject(:item) { model.last }
it { expect(item.domain).not_to eq nil }
it { expect(item.path).not_to ... |
shirasagi/opendata | spec/factories/cms/parts.rb | FactoryGirl.define do
trait :cms_part do
site_id { cms_site.id }
user_id { cms_user.id }
name "#{unique_id}"
filename { "#{name}.part.html" }
route "cms/free"
end
factory :cms_part, class: Cms::Part, traits: [:cms_part] do
mobile_view :show
end
factory :cms_part_base, class: Cms::Pa... |
shirasagi/opendata | spec/features/opendata/agents/nodes/idea/search_idea_spec.rb | require 'spec_helper'
describe "opendata_search_ideas", dbscope: :example, js: true do
let(:site) { cms_site }
let(:layout) { create_cms_layout }
let(:node_idea) { create :opendata_node_idea, cur_site: site, layout_id: layout.id }
let!(:node_idea_search) { create(:opendata_node_search_idea, cur_site: site, cur... |
shirasagi/opendata | app/models/concerns/opendata/addon/my_idea_list.rb | module Opendata::Addon::MyIdeaList
extend SS::Addon
extend ActiveSupport::Concern
include Cms::Addon::PageList
public
def template_variable_get(item, name)
if name.start_with?('idea_')
if index = name.index('.')
param = name[index + 1..-1]
name = name[0..index - 1]
... |
shirasagi/opendata | app/models/concerns/opendata/addon/my_dataset_list.rb | <filename>app/models/concerns/opendata/addon/my_dataset_list.rb
module Opendata::Addon::MyDatasetList
extend SS::Addon
extend ActiveSupport::Concern
include Cms::Addon::PageList
public
def template_variable_get(item, name)
if name.start_with?('dataset_')
if name == 'dataset_name'
ER... |
shirasagi/opendata | app/models/chorg/initializer.rb | module Chorg
class Initializer
end
end
|
shirasagi/opendata | spec/models/ldap/import_job_spec.rb | require 'spec_helper'
describe Ldap::ImportJob, ldap: true do
describe "#call" do
context "when no ldap connection is set" do
subject { Ldap::ImportJob.new }
it "should not raise errors" do
expect { subject.call(cms_site.id, cms_user.id, "pass") }.to raise_error
end
end
contex... |
shirasagi/opendata | app/controllers/concerns/ss/trans_sid_filter.rb | module SS::TransSidFilter
extend ActiveSupport::Concern
included do
if defined?(Jpmobile)
before_action :set_trans_sid
trans_sid :none
end
end
private
def mobile_path?
filters = request.env["ss.filters"]
return false if filters.blank?
filters.include?(:mobile)
end... |
shirasagi/opendata | spec/features/rdf/props_spec.rb | require 'spec_helper'
describe "rdf_props", type: :feature, dbscope: :example do
let(:site) { cms_site }
let!(:category) { create(:opendata_node_category, cur_site: site) }
let(:vocab) { create(:rdf_vocab, site: site) }
let(:index_path) { rdf_props_props_path site.host, vocab.id }
let(:new_path) { new_rdf_pr... |
shirasagi/opendata | spec/factories/article/pages.rb | <filename>spec/factories/article/pages.rb
FactoryGirl.define do
factory :article_page, class: Article::Page, traits: [:cms_page] do
transient do
site nil
node nil
end
cur_site { site ? site : cms_site }
filename { node ? "#{node.filename}/#{name}.html" : "dir/#{unique_id}.html" }
rout... |
shirasagi/opendata | app/controllers/concerns/ss/auth_filter.rb | <reponame>shirasagi/opendata<filename>app/controllers/concerns/ss/auth_filter.rb
module SS::AuthFilter
extend ActiveSupport::Concern
included do
cattr_accessor(:user_class) { SS::User }
end
public
def get_user_by_session
return nil unless session[:user]
u = SS::Crypt.decrypt(session[:user... |
shirasagi/opendata | app/controllers/concerns/opendata/idea/comment_filter.rb | <gh_stars>1-10
module Opendata::Idea::CommentFilter
extend ActiveSupport::Concern
private
def update_commented_count(member_ids, count)
member_ids.each do |member_id|
notice = Opendata::MemberNotice.where({site_id: @cur_site.id, member_id: member_id}).first
if notice
not... |
shirasagi/opendata | spec/features/cms/contents_spec.rb | <reponame>shirasagi/opendata
require 'spec_helper'
describe "cms_contents", dbscope: :example, type: :feature do
subject(:site) { cms_site }
subject(:index_path) { cms_contents_path site.host }
it "without login" do
visit index_path
expect(current_path).to eq sns_login_path
end
it "without auth" do... |
shirasagi/opendata | app/controllers/rdf/apis/classes_controller.rb | <reponame>shirasagi/opendata
class Rdf::Apis::ClassesController < ApplicationController
include Cms::ApiFilter
model Rdf::Class
before_action :set_vocab_id
private
def vocab_options
vocabs = Rdf::Vocab.site(@cur_site).each.select do |vocab|
vocab.allowed?(:read, @cur_user, site: @cur_site)
... |
shirasagi/opendata | app/controllers/opendata/agents/parts/idea/idea_controller.rb | <filename>app/controllers/opendata/agents/parts/idea/idea_controller.rb
class Opendata::Agents::Parts::Idea::IdeaController < ApplicationController
include Cms::PartFilter::View
include Opendata::UrlHelper
helper Opendata::ListHelper
public
def index
@node_url = "#{search_ideas_path}?sort=#{@cur_part... |
shirasagi/opendata | app/controllers/concerns/cms/searchable_crud_filter.rb | <filename>app/controllers/concerns/cms/searchable_crud_filter.rb
module Cms::SearchableCrudFilter
extend ActiveSupport::Concern
public
def index
raise "403" unless @model.allowed?(:read, @cur_user, site: @cur_site)
@items = @model.site(@cur_site).
allow(:edit, @cur_user, site: @cur_site).
... |
shirasagi/opendata | app/models/ldap/extensions/ldap_entity.rb | class Ldap::Extensions::LdapEntity < Hash
def mongoize
self.to_h
end
class << self
def demongoize(object)
if object.present?
ret = Ldap::Extensions::LdapEntity.new
object.symbolize_keys.each do |key, value|
ret[key] = value
end
ret
else
Ldap::... |
shirasagi/opendata | app/models/concerns/cms/addon/import/group.rb | <reponame>shirasagi/opendata<filename>app/models/concerns/cms/addon/import/group.rb
require "csv"
module Cms::Addon::Import
module Group
extend ActiveSupport::Concern
extend SS::Addon
included do
attr_accessor :in_file, :imported
permit_params :in_file
end
module ClassMethods
... |
shirasagi/opendata | app/models/concerns/rdf/object.rb | module Rdf::Object
extend ActiveSupport::Concern
extend SS::Translation
include SS::Document
include Rdf::Reference::Vocab
included do
seqid :id
field :name, type: String
field :labels, type: Rdf::Extensions::LangHash
field :comments, type: Rdf::Extensions::LangHash
permit_params :name, ... |
shirasagi/opendata | lib/ldap/entry.rb | class Ldap::Entry
include Enumerable
include Comparable
def initialize(connection, entry)
@connection = connection
@entry = entry
end
class << self
def find(connection, dn)
connection.find(dn, self)
end
end
def dn
self.class.normalize(@entry.dn)
end
def [](name)
self.... |
shirasagi/opendata | spec/factories/key_visual/pages.rb | <filename>spec/factories/key_visual/pages.rb
FactoryGirl.define do
factory :key_visual_image, class: KeyVisual::Image, traits: [:cms_page] do
filename { "dir/#{unique_id}" }
route "key_visual/image"
link_url "/example/"
file_id 1
end
end
|
shirasagi/opendata | spec/features/opendata/licenses_spec.rb | require 'spec_helper'
describe "opendata_licenses", type: :feature, dbscope: :example do
let(:site) { cms_site }
let(:node) { create_once :opendata_node_dataset, name: "opendata_dataset" }
let(:index_path) { opendata_licenses_path site.host, node }
let(:new_path) { new_opendata_license_path site.host, node }
... |
shirasagi/opendata | app/helpers/application_helper.rb | module ApplicationHelper
def tryb(&block)
begin
block.call
rescue NoMethodError
nil
end
end
def t(key, opts = {})
opts[:scope] = [:views] if key !~ /\./ && !opts[:scope]
I18n.t key, opts.merge(default: key.to_s.humanize)
end
def br(str)
h(str.to_s).gsub(/(\r\n?)|(\n)/, "<... |
shirasagi/opendata | spec/helpers/opendata/url_helper_spec.rb | <gh_stars>1-10
require 'spec_helper'
describe Opendata::UrlHelper, type: :helper, dbscope: :example do
let(:icon_file_path) { "#{Rails.root}/spec/fixtures/ss/logo.png" }
let(:icon_file) { Fs::UploadedFile.create_from_file(icon_file_path) }
describe ".member_icon" do
context "when menber has icon" do
l... |
shirasagi/opendata | app/models/concerns/cms/model/page.rb | module Cms::Model::Page
extend ActiveSupport::Concern
extend SS::Translation
include Cms::Content
include Cms::Reference::Layout
included do
class_variable_set(:@@_after_generate_file_callbacks, [])
class_variable_set(:@@_after_remove_file_callbacks, [])
class_variable_set(:@@_after_rename_file_c... |
shirasagi/opendata | app/models/rdf/property_expander.rb | class Rdf::PropertyExpander
DEPTH_LIMIT = 5.freeze
def initialize(depth_limit = DEPTH_LIMIT)
@depth_limit = depth_limit
@vocab_cache = {}
@vocab_cache.default_proc = ->(hash, key) { set_vocab(hash, key) }
@class_cache = {}
@class_cache.default_proc = ->(hash, key) { set_class(hash, key) }
@... |
shirasagi/opendata | app/models/concerns/cms/model/part.rb | <reponame>shirasagi/opendata
module Cms::Model::Part
extend ActiveSupport::Concern
extend SS::Translation
include Cms::Content
included do |mod|
store_in collection: "cms_parts"
set_permission_name "cms_parts"
field :route, type: String
field :mobile_view, type: String, default: "show"
fie... |
shirasagi/opendata | config/initializers/ss/rb_config.rb | #> Use RbConfig instead of obsolete and deprecated Config.
#Object.send :remove_const, :Config if defined? Object::Config
#Config = RbConfig
|
shirasagi/opendata | app/controllers/sys/test_controller.rb | <filename>app/controllers/sys/test_controller.rb<gh_stars>1-10
class Sys::TestController < ApplicationController
include Sys::BaseFilter
public
def index
redirect_to sys_test_mail_path
end
end
|
shirasagi/opendata | app/controllers/concerns/mobile/public_filter.rb | <reponame>shirasagi/opendata<filename>app/controllers/concerns/mobile/public_filter.rb<gh_stars>1-10
module Mobile::PublicFilter
extend ActiveSupport::Concern
public
def mobile_path?
filters.include?(:mobile)
end
private
def set_request_path_with_mobile
return if @cur_path !~ /^#{SS.conf... |
shirasagi/opendata | spec/support/opendata/app.rb | <reponame>shirasagi/opendata<filename>spec/support/opendata/app.rb<gh_stars>1-10
RSpec.configuration.before(:suite) do
# override zip_dir method to write zip file to tmp dir
class Opendata::App
class << self
alias_method :zip_dir_orig, :zip_dir
@@tmp_dir = Pathname(::Dir.mktmpdir)
def zip_dir
... |
shirasagi/opendata | spec/features/opendata/agents/nodes/mypage/idea/my_idea_spec.rb | require 'spec_helper'
describe "opendata_agents_nodes_my_idea", dbscope: :example do
let(:site) { cms_site }
let!(:node) { create_once :opendata_node_idea, name: "opendata_agents_nodes_idea" }
let!(:member) { create_once :opendata_node_member }
let!(:upper_html) { '<a href="new/">新規作成</a>' }
let!(:node_mypa... |
shirasagi/opendata | app/controllers/cms/public_controller.rb | class Cms::PublicController < ApplicationController
include Cms::PublicFilter
after_action :put_access_log
after_action :render_mobile, if: ->{ mobile_path? }
private
def put_access_log
#
end
end
|
shirasagi/opendata | app/models/opendata/dataset.rb | class Opendata::Dataset
include Cms::Model::Page
include ::Workflow::Addon::Approver
include Opendata::Addon::Resource
include Opendata::Addon::UrlResource
include Opendata::Addon::Category
include Opendata::Addon::Area
include Opendata::Addon::DatasetGroup
include Opendata::Reference::Member
include ... |
shirasagi/opendata | db/seeds/demo/load.rb | Dir.chdir @root = File.dirname(__FILE__)
@site = SS::Site.find_by host: ENV["site"]
## -------------------------------------
puts "# files"
Dir.glob "files/**/*.*" do |file|
puts name = file.sub(/^files\//, "")
Fs.binwrite "#{@site.path}/#{name}", File.binread(file)
end
def save_ss_files(path, data)
puts path
... |
shirasagi/opendata | app/models/opendata/idea.rb | class Opendata::Idea
include Cms::Model::Page
include ::Workflow::Addon::Approver
include Opendata::Addon::Comment
include Opendata::Addon::Category
include Opendata::Addon::Area
include Opendata::Reference::Member
include Opendata::Common
include Cms::Addon::Release
include Contact::Addon::Page
inc... |
shirasagi/opendata | lib/ss/rake_runner.rb | <reponame>shirasagi/opendata
class SS::RakeRunner
NULL_DEVICE = "/dev/null"
class << self
private
def do_spawn(task, *args)
Rails.logger.debug "spawn: bundle exec rake #{task} #{args.join(" ")}"
spawn({}, "bundle", "exec", "rake", task, *args, { in: NULL_DEVICE, out: NULL_DEVICE, err: NUL... |
shirasagi/opendata | spec/support/ss/file.rb | <reponame>shirasagi/opendata
class SS::File
def self.root
"#{Rails.root}/tmp/ss_files"
end
end
|
shirasagi/opendata | spec/features/cms/users_spec.rb | require 'spec_helper'
describe "cms_users", dbscope: :example do
subject(:site) { cms_site }
subject(:group) { cms_group }
subject(:item) { create(:cms_test_user, group: group) }
subject(:index_path) { cms_users_path site.host }
subject(:new_path) { new_cms_user_path site.host }
subject(:show_path) { cms_u... |
shirasagi/opendata | app/controllers/member/agents/nodes/login_controller.rb | class Member::Agents::Nodes::LoginController < ApplicationController
include Cms::NodeFilter::View
include Member::LoginFilter
skip_filter :logged_in?, only: [:login, :logout, :callback, :failure]
private
def get_params
params.require(:item).permit(:email, :password)
end
def set_member_and_... |
shirasagi/opendata | spec/features/chorg/changesets_spec.rb | require 'spec_helper'
describe "chorg_changesets", dbscope: :example do
let(:site) { cms_site }
let(:revision) { create(:revision, site_id: site.id) }
let(:index_path) { chorg_changesets_changesets_path site.host, revision.id, "add" }
let(:revision_show_path) { chorg_revisions_revision_path site.host, revision... |
shirasagi/opendata | app/controllers/facility/pages_controller.rb | <reponame>shirasagi/opendata<gh_stars>1-10
class Facility::PagesController < ApplicationController
include Cms::BaseFilter
include Cms::NodeFilter
include Facility::PageFilter
model Facility::Node::Page
prepend_view_path "app/views/cms/node/nodes"
menu_view "facility/page/menu"
private
def fix_para... |
shirasagi/opendata | app/models/concerns/cms/addon/sns_share.rb | module Cms::Addon
module SnsShare
extend ActiveSupport::Concern
extend SS::Addon
SERVICES = %w(fb_like fb_share twitter hatena google evernote)
included do
field :sns_share_states, type: Hash
field :sns_share_orders, type: Hash
permit_params sns_share_states: SERVICES, sns_share_or... |
shirasagi/opendata | spec/features/cms/node/parts_spec.rb | <gh_stars>1-10
require 'spec_helper'
describe "cms_node_parts" do
subject(:site) { cms_site }
subject(:node) { create_once :cms_node_page, name: "cms" }
subject(:item) { Cms::Part.last }
subject(:index_path) { node_parts_path site.host, node }
subject(:new_path) { new_node_part_path site.host, node }
subje... |
shirasagi/opendata | spec/models/ss/file_spec.rb | require 'spec_helper'
describe SS::File do
describe "shirasagi-434" do
before do
@tmpdir = ::Dir.mktmpdir
@file_path = "#{@tmpdir}/#{filename}"
File.open(@file_path, "wb") do |file|
file.write [1]
end
end
after do
::FileUtils.rm_rf(@tmpdir)
end
before do
... |
shirasagi/opendata | spec/factories/member/nodes.rb | FactoryGirl.define do
factory :member_node_login, class: Member::Node::Login, traits: [:cms_node] do
cur_site { cms_site }
route "member/login"
filename { SS.config.oauth.prefix_path.sub(/^\//, '') || "auth" }
twitter_oauth "enabled"
twitter_client_id { "#{unique_id}" }
twitter_client_secret {... |
shirasagi/opendata | app/models/concerns/ss/model/group.rb | module SS::Model::Group
extend ActiveSupport::Concern
extend SS::Translation
include SS::Document
include Ldap::Addon::Group
attr_accessor :in_password
included do
store_in collection: "ss_groups"
index({ name: 1 }, { unique: true })
seqid :id
field :name, type: String
field :order, t... |
shirasagi/opendata | app/controllers/concerns/ss/file_filter.rb | <filename>app/controllers/concerns/ss/file_filter.rb
module SS::FileFilter
extend ActiveSupport::Concern
private
def append_view_paths
append_view_path "app/views/ss/crud/files"
super
end
def set_last_modified
response.headers["Last-Modified"] = CGI::rfc1123_date(@item.updated.in_tim... |
shirasagi/opendata | config/routes/opendata/mypage/routes.rb | SS::Application.routes.draw do
Opendata::Initializer
concern :deletion do
get :delete, on: :member
end
content "opendata" do
resources :mypages, concerns: :deletion, module: "mypage"
end
node "opendata" do
get "mypage/(index.html)" => "public#index", cell: "nodes/mypage/mypage"
get "mypa... |
shirasagi/opendata | app/controllers/cms/import_controller.rb | <reponame>shirasagi/opendata
class Cms::ImportController < ApplicationController
include Cms::BaseFilter
include Cms::CrudFilter
model Cms::Node::ImportNode
navi_view "cms/main/navi"
menu_view nil
public
def import
@item = @model.new get_params
@item.cur_site = @cur_site
result = @i... |
shirasagi/opendata | app/helpers/opendata/list_helper.rb | module Opendata::ListHelper
def render_page_list(&block)
cur_item = @cur_part || @cur_node
cur_item.cur_date = @cur_date
h = []
h << cur_item.upper_html.html_safe if cur_item.upper_html.present?
if block_given?
h << capture(&block)
else
@items.each do |item|
if cur_item.l... |
shirasagi/opendata | spec/features/article/pages_spec.rb | require 'spec_helper'
describe "article_pages", dbscope: :example do
let(:site) { cms_site }
let(:node) { create_once :article_node_page, filename: "docs", name: "article" }
let(:item) { create(:article_page, node: node) }
let(:index_path) { article_pages_path site.host, node }
let(:new_path) { new_article_p... |
shirasagi/opendata | app/models/oauth/base.rb | require 'oauth2'
module Oauth::Base
def site
host = @env["HTTP_X_FORWARDED_HOST"] || @env["HTTP_HOST"]
@site ||= SS::Site.find_by_domain host
end
def node
path = request.env["REQUEST_PATH"]
@node ||= Member::Node::Login.site(site).in_path(path).sort(depth: -1).first
end
def client_id
@c... |
shirasagi/opendata | spec/requests/article/pages_spec.rb | <reponame>shirasagi/opendata<gh_stars>1-10
require 'spec_helper'
describe "Article::PagesController", type: :request, dbscope: :example do
let!(:group) { cms_group }
let!(:site) { cms_site }
let!(:node) { create(:article_node_page) }
let(:auth_token_path) { sns_auth_token_path(format: :json) }
let(:index_pat... |
shirasagi/opendata | spec/features/cms/import_spec.rb | require 'spec_helper'
describe "cms_import" do
subject(:site) { cms_site }
subject(:index_path) { cms_import_path site.host }
it "without login" do
visit index_path
expect(current_path).to eq sns_login_path
end
it "without auth" do
login_ss_user
visit index_path
expect(status_code).to e... |
shirasagi/opendata | app/models/concerns/inquiry/addon/captcha.rb | module Inquiry::Addon
module Captcha
extend ActiveSupport::Concern
extend SS::Addon
included do
field :inquiry_captcha, type: String, default: "enabled"
permit_params :inquiry_captcha
end
public
def inquiry_captcha_options
[
[I18n.t('inquiry.options.state.enab... |
shirasagi/opendata | app/controllers/concerns/opendata/api/tag_show_filter.rb | <reponame>shirasagi/opendata
module Opendata::Api::TagShowFilter
extend ActiveSupport::Concern
include Opendata::Api
public
def tag_show
help = t("opendata.api.tag_show_help")
id = params[:id]
id = URI.decode(id) if id
if !id
error = {__type: "Validation Error", id... |
shirasagi/opendata | app/controllers/opendata/agents/nodes/app/app_category_controller.rb | class Opendata::Agents::Nodes::App::AppCategoryController < ApplicationController
include Cms::NodeFilter::View
include Opendata::UrlHelper
include Opendata::App::AppFilter
private
def pages
@cur_node.cur_subcategory = params[:name]
@item = @cur_node.related_category
raise "404" unless @i... |
shirasagi/opendata | spec/helpers/opendata/list_helper_spec.rb | <filename>spec/helpers/opendata/list_helper_spec.rb
require 'spec_helper'
describe Opendata::ListHelper, type: :helper, dbscope: :example do
describe ".render_page_list" do
context "without block" do
subject { helper.render_page_list }
before do
@cur_site = cms_site
create(:opendata_... |
shirasagi/opendata | app/models/concerns/cms/addon/node_setting.rb | <filename>app/models/concerns/cms/addon/node_setting.rb
module Cms::Addon
module NodeSetting
extend ActiveSupport::Concern
extend SS::Addon
included do
field :view_route, type: String
permit_params :view_route
end
end
end
|
shirasagi/opendata | spec/factories/opendata/dataset_groups.rb | FactoryGirl.define do
factory :opendata_dataset_group, class: Opendata::DatasetGroup do
transient do
site nil
user nil
categories nil
end
name { "#{unique_id}" }
site_id { site.present? ? site.id : cms_site.id }
user_id { user.present? ? user.id : nil }
category_ids { catego... |
shirasagi/opendata | app/models/concerns/ss/model/role.rb | <filename>app/models/concerns/ss/model/role.rb
module SS::Model::Role
extend ActiveSupport::Concern
extend SS::Translation
include SS::Document
include SS::Reference::User
included do
cattr_accessor(:_permission_names) { [] }
cattr_accessor(:_module_permission_names) { {} }
seqid :id
field :... |
shirasagi/opendata | lib/ldap/group.rb | class Ldap::Group < Ldap::Entry
def initialize(connection, entry)
super(connection, entry)
end
end
class Ldap::OrganizationalUnit < Ldap::Group
public_class_method :new
def name
value(:ou)
end
def contact_tel
value(:telephoneNumber)
end
def self.support?(object_classes)
object_classe... |
shirasagi/opendata | app/models/concerns/cms/addon/html.rb | module Cms::Addon
module Html
extend ActiveSupport::Concern
extend SS::Addon
included do
field :html, type: String, metadata: { form: :text }
permit_params :html
end
end
end
|
shirasagi/opendata | lib/tasks/cms/seeds/export.rake | <reponame>shirasagi/opendata<filename>lib/tasks/cms/seeds/export.rake
namespace :cms do
def find_layout(site, layout)
ret = Cms::Layout.site(site).where(_id: layout).first
ret ||= Cms::Layout.site(site).where(filename: layout).first
ret ||= Cms::Layout.site(site).where(name: layout).first
ret
end
... |
shirasagi/opendata | spec/support/ss/mongoid.rb | # mongoid
shared_examples "mongoid#save" do
it { expect { build(factory).save! }.not_to raise_error }
end
shared_examples "mongoid#find" do
it { expect(model.first).not_to eq nil }
#it { expect(model.all.size).not_to eq 0 }
end
module Mongoid
module Tasks
module Database
private
# rewrite lo... |
shirasagi/opendata | spec/features/opendata/agents/nodes/mypage/dataset/my_dataset/resources_spec.rb | require 'spec_helper'
describe "opendata_agents_nodes_my_dataset_resources", dbscope: :example do
let(:site) { cms_site }
let(:member) { opendata_member(site: site) }
let!(:node_member) { create :opendata_node_member }
let!(:node_search_dataset) { create_once :opendata_node_search_dataset, basename: "dataset/s... |
shirasagi/opendata | spec/features/opendata/agents/nodes/member_spec.rb | <reponame>shirasagi/opendata
require 'spec_helper'
describe "opendata_agents_nodes_member", dbscope: :example do
let(:site) { cms_site }
let(:node_member) { create_once :opendata_node_member }
let(:index_path) { "#{node_member.url}index.html" }
describe "index" do
it do
page.driver.browser.with_sess... |
shirasagi/opendata | spec/models/chorg/main_runner_spec.rb | require 'spec_helper'
describe Chorg::MainRunner, dbscope: :example do
let(:root_group) { create(:revision_root_group) }
let(:site) { create(:cms_site, group_ids: [root_group.id]) }
context "with add" do
let(:revision) { create(:revision, site_id: site.id) }
let(:changeset) { create(:add_changeset, revi... |
shirasagi/opendata | spec/models/opendata/license_spec.rb | require 'spec_helper'
describe Opendata::License, dbscope: :example do
context "check attributes with typical url resource" do
let(:site) { cms_site }
let(:license_logo_file_path) { Rails.root.join("spec", "fixtures", "ss", "logo.png") }
let(:license_logo_file) { Fs::UploadedFile.create_from_file(license... |
shirasagi/opendata | spec/features/opendata/dataset/dataset_groups_spec.rb | <filename>spec/features/opendata/dataset/dataset_groups_spec.rb<gh_stars>1-10
require 'spec_helper'
describe "opendata_dataset_groups", type: :feature, dbscope: :example do
let(:site) { cms_site }
let(:node) { create_once :opendata_node_dataset, name: "opendata_dataset" }
let(:index_path) { opendata_dataset_grou... |
shirasagi/opendata | config/routes/opendata/idea/routes.rb | SS::Application.routes.draw do
Opendata::Initializer
concern :deletion do
get :delete, on: :member
end
content "opendata" do
resources :ideas, concerns: :deletion, module: :idea do
resources :comments, concerns: :deletion
end
resources :idea_categories, concerns: :deletion, module: :ide... |
shirasagi/opendata | app/models/concerns/cms/addon/body.rb | <gh_stars>1-10
module Cms::Addon
module Body
extend ActiveSupport::Concern
extend SS::Addon
included do
field :html, type: String, metadata: { form: :text }
field :markdown, type: String
permit_params :html, :markdown
validate :convert_markdown, if: -> { SS.config.cms.html_editor... |
shirasagi/opendata | app/models/concerns/ads/addon/page_list.rb | <reponame>shirasagi/opendata<gh_stars>1-10
module Ads::Addon
module PageList
extend ActiveSupport::Concern
extend SS::Addon
included do
field :link_action, type: String
field :link_target, type: String
field :sort, type: String
field :with_category, type: String
field :upper... |
shirasagi/opendata | app/models/sys/group.rb | class Sys::Group
include SS::Model::Group
include Sys::Permission
include Contact::Addon::Group
set_permission_name "sys_users", :edit
attr_accessor :sys_role_ids
permit_params :sys_role_ids
public
def users
SS::User.in(group_ids: id)
end
end
|
shirasagi/opendata | spec/features/opendata/agents/parts/dataset/dataset_group_spec.rb | require 'spec_helper'
describe "opendata_agents_nodes_dataset_group", dbscope: :example do
let(:site) { cms_site }
let!(:category) { create :opendata_node_category, basename: "bunya/kurashi" }
let!(:dataset_group) { create :opendata_dataset_group, categories: [ category ] }
let(:node) { create :opendata_node_d... |
shirasagi/opendata | lib/ldap/user.rb | <reponame>shirasagi/opendata<filename>lib/ldap/user.rb
class Ldap::User < Ldap::Entry
def initialize(connection, entry)
super(connection, entry)
end
def authenticate(password)
config = @connection.config.to_h.merge({ username: dn, password: password })
new_connection = Ldap::Connection.connect(config... |
shirasagi/opendata | app/controllers/application_controller.rb | class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
#before_action -> { FileUtils.touch "#{Rails.root}/Gemfile" } if Rails.env.to_s == "development"
before_action :set... |
shirasagi/opendata | app/controllers/sns/login_controller.rb | <reponame>shirasagi/opendata
class Sns::LoginController < ApplicationController
include Sns::BaseFilter
protect_from_forgery except: :remote_login
skip_filter :logged_in?, only: [:login, :remote_login]
navi_view nil
private
def get_params
params.require(:item).permit(:uid, :email, :password)
... |
shirasagi/opendata | app/models/chorg/revision.rb | class Chorg::Revision
extend SS::Translation
include SS::Document
include SS::Reference::Site
include Cms::SitePermission
include Voice::Lockable
set_permission_name "cms_users", :edit
attr_accessor :add_newly_created_group_to_site
seqid :id
field :name, type: String
has_many :changesets, class_n... |
shirasagi/opendata | app/controllers/cms/preview_controller.rb | class Cms::PreviewController < ApplicationController
include Cms::BaseFilter
include Cms::PublicFilter
include Fs::FileFilter
before_action :set_group
before_action :set_path_with_preview, prepend: true
after_action :render_preview, if: ->{ @file =~ /\.html$/ }
after_action :render_mobile, if: ->{ mobile... |
shirasagi/opendata | app/helpers/ss/editor_helper.rb | <filename>app/helpers/ss/editor_helper.rb
module SS::EditorHelper
CODE_EXT_MODES = {
html: :htmlmixed,
scss: :css,
js: :javascript,
coffee: :coffeescript,
}
CODE_MODE_FILES = {
htmlmixed: %w(xml javascript css vbscript htmlmixed),
}
def code_editor(elem, opts = {})
mode = opts[:mo... |
shirasagi/opendata | app/controllers/sns/auth_token_controller.rb | class Sns::AuthTokenController < ApplicationController
public
def index
@item = form_authenticity_token
response.headers['X-CSRF-Token'] = @item
respond_to do |format|
format.html do
response.headers['Content-Type'] = "text/plain"
render layout: false
end
... |
shirasagi/opendata | spec/features/workflow/search_approvers_spec.rb | require 'spec_helper'
describe "workflow_search_approvers" do
subject(:site) { cms_site }
subject(:user) { cms_user }
subject(:group) { cms_group }
subject(:index_path) { workflow_search_approvers_path site.host }
it "without login" do
visit index_path
expect(current_path).to eq sns_login_path
end... |
shirasagi/opendata | app/models/concerns/rss/addon/import.rb | module Rss::Addon
module Import
extend ActiveSupport::Concern
extend SS::Addon
RSS_REFRESH_METHOD_MANUAL = 'manual'.freeze
RSS_REFRESH_METHOD_AUTO = 'auto'.freeze
RSS_REFRESH_METHODS = [ RSS_REFRESH_METHOD_MANUAL, RSS_REFRESH_METHOD_AUTO ].freeze
included do
field :rss_url, type: Strin... |
shirasagi/opendata | app/controllers/sns/mypage_controller.rb | <reponame>shirasagi/opendata
class Sns::MypageController < ApplicationController
include Sns::BaseFilter
public
def index
#mypage
@sites = []
SS::Site.each do |site|
if @cur_user.groups.in(name: site.groups.pluck(:name).map{ |name| /^#{Regexp.escape(name)}(\/|$)/ } ).present?
... |
shirasagi/opendata | spec/models/opendata/resource_spec.rb | require 'spec_helper'
describe Opendata::Resource, dbscope: :example do
let(:site) { cms_site }
let!(:node_search_dataset) { create(:opendata_node_search_dataset) }
let(:node) { create(:opendata_node_dataset) }
let(:dataset) { create(:opendata_dataset, node: node) }
let(:license_logo_file) { upload_file(Rail... |
shirasagi/opendata | app/controllers/opendata/agents/tasks/node/apps_controller.rb | <reponame>shirasagi/opendata<gh_stars>1-10
class Opendata::Agents::Tasks::Node::AppsController < ApplicationController
include Cms::PublicFilter::Node
public
def generate
generate_node @node
end
end
|
shirasagi/opendata | app/models/opendata/license.rb | class Opendata::License
include SS::Document
include SS::Reference::User
include SS::Reference::Site
include SS::Relation::File
include Cms::Addon::GroupPermission
set_permission_name :opendata_datasets
seqid :id
field :state, type: String, default: "public"
field :name, type: String
field :relate... |
shirasagi/opendata | app/controllers/faq/agents/parts/search_controller.rb | <reponame>shirasagi/opendata
class Faq::Agents::Parts::SearchController < ApplicationController
include Cms::PartFilter::View
include Cms::PublicFilter::Layout
include Mobile::PublicFilter
helper Cms::ListHelper
public
def index
@search_node = @cur_part.search_node.present? ? @cur_part.search_node... |
shirasagi/opendata | app/models/opendata/appfile.rb | <reponame>shirasagi/opendata<filename>app/models/opendata/appfile.rb
class Opendata::Appfile
include SS::Document
include SS::Relation::File
include Opendata::TsvParseable
include Opendata::AllowableAny
include Opendata::Common
attr_accessor :workflow, :status
seqid :id
field :filename, type: String
... |
shirasagi/opendata | app/models/key_visual/image.rb | <reponame>shirasagi/opendata
class KeyVisual::Image
include Cms::Model::Page
include SS::Relation::File
include Cms::Addon::Release
include Cms::Addon::ReleasePlan
include Cms::Addon::GroupPermission
include History::Addon::Backup
set_permission_name "key_visual_images"
field :link_url, type: String
... |
shirasagi/opendata | spec/features/opendata/agents/parts/dataset/dataset_spec.rb | <filename>spec/features/opendata/agents/parts/dataset/dataset_spec.rb
require 'spec_helper'
describe "opendata_agents_nodes_dataset", dbscope: :example do
let(:site) { cms_site }
let!(:node_category) { create :opendata_node_category, basename: "bunya/kurashi" }
let!(:node_search_dataset) { create :opendata_node_... |
shirasagi/opendata | db/seeds/users/load.rb | <filename>db/seeds/users/load.rb
Dir.chdir @root = File.dirname(__FILE__)
@site = SS::Site.find_by host: ENV["site"]
## -------------------------------------
puts "# groups"
def save_group(data)
puts data[:name]
cond = { name: data[:name] }
item = SS::Group.find_or_create_by cond
item.update_attributes! data... |
shirasagi/opendata | spec/models/article/page_spec.rb | <reponame>shirasagi/opendata
require 'spec_helper'
describe Article::Page, dbscope: :example do
# subject(:model) { Article::Page }
# subject(:factory) { :article_page }
#
# it_behaves_like "mongoid#save"
# it_behaves_like "mongoid#find"
describe "#attributes" do
subject(:item) { create :article_page ... |
shirasagi/opendata | lib/voice/converter.rb | <reponame>shirasagi/opendata
module Voice::Converter
class << self
public
def convert(site_id, html, output)
texts = Voice::Scraper::DEFAULT_INSTANCE.extract_text html
type = SS.config.voice.type
config = SS.config.voice[type]
tts = Voice::TextToSpeechFactory.create(type, c... |
shirasagi/opendata | app/controllers/cms/contents_controller.rb | <filename>app/controllers/cms/contents_controller.rb
class Cms::ContentsController < ApplicationController
include Cms::BaseFilter
navi_view "cms/main/navi"
private
def set_crumbs
@crumbs << [:"cms.content", action: :index]
end
public
def index
@model = Cms::Node
self.menu_view_... |
shirasagi/opendata | config/routes/chorg/routes.rb | SS::Application.routes.draw do
# Chorg::Initializer
concern :deletion do
get :delete, on: :member
end
namespace("chorg_results", path: ".:site/chorgs/revisions/:rid", module: "chorg", id: /\w+/) do
resources :results, only: [:index, :show]
end
namespace("chorg_revisions", path: ".:site/chorgs", ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.